forked from unidoc/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappproperties_test.go
74 lines (65 loc) · 1.98 KB
/
appproperties_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2017 FoxyUtils ehf. All rights reserved.
//
// Use of this software package and source code is governed by the terms of the
// UniDoc End User License Agreement (EULA) that is available at:
// https://unidoc.io/eula/
// A trial license code for evaluation can be obtained at https://unidoc.io.
package common_test
import (
"fmt"
"testing"
"github.com/unidoc/unioffice/common"
)
func TestNewAppDefaultProperties(t *testing.T) {
ap := common.NewAppProperties()
if ap.X() == nil {
t.Errorf("expected non-nil internal element")
}
if got := ap.Application(); got != "github.com/unidoc/unioffice" {
t.Errorf("unexpected application: %s", got)
}
ap.X().Application = nil
if got := ap.Application(); got != "" {
t.Errorf("unexpected application: %s", got)
}
var major, minor, patch int64
fmt.Sscanf(common.Version, "%d.%d.%d", &major, &minor, &patch)
fv := float64(major) + float64(minor)/10000.0
if got := ap.ApplicationVersion(); got != fmt.Sprintf("%07.4f", fv) {
t.Errorf("unexpected application version: %s", got)
}
ap.X().AppVersion = nil
if got := ap.ApplicationVersion(); got != "" {
t.Errorf("unexpected application version: %s", got)
}
}
func TestAppPropertiesSetApplication(t *testing.T) {
ap := common.NewAppProperties()
if ap.X() == nil {
t.Errorf("expected non-nil internal element")
}
ap.SetApplication("foo")
if got := ap.Application(); got != "foo" {
t.Errorf("unexpected application: %s", got)
}
}
func TestAppPropertiesSetApplicationVersion(t *testing.T) {
ap := common.NewAppProperties()
if ap.X() == nil {
t.Errorf("expected non-nil internal element")
}
ap.SetApplicationVersion("foo")
if got := ap.ApplicationVersion(); got != "foo" {
t.Errorf("unexpected application: %s", got)
}
}
func TestAppPropertiesSetCompany(t *testing.T) {
ap := common.NewAppProperties()
if ap.X() == nil {
t.Errorf("expected non-nil internal element")
}
ap.SetCompany("foo")
if got := ap.Company(); got != "foo" {
t.Errorf("unexpected company: %s", got)
}
}