2019-07-25 19:43:46 +03:00
|
|
|
// Copyright 2017 FoxyUtils ehf. All rights reserved.
|
2017-10-10 18:35:41 -04:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by the terms of the Affero GNU General
|
|
|
|
// Public License version 3.0 as published by the Free Software Foundation and
|
|
|
|
// appearing in the file LICENSE included in the packaging of this file. A
|
Functions2 (#348)
* MATCH, IFS, MAXA, MINA
* OFFSET fixed
* ISBLANK, ISERR, ISERROR, ISEVEN ,ISFORMULA, ISNONTEXT, ISNUMBER, ISODD, ISTEXT
* ISLEAPYEAR, ISLOGICAL, ISNA, ISREF
* FIND, FINDB
* SEARCH, SEARCHB
* CONCAT, CONCATENATE
* YEAR, YEARFRAC
* CONCAT is fixed, now TRUE and FALSE are concatenated instead of 1 and 0 in case of boolean results
* NOW, TODAY, TIME, TIMEVALUE
* DATE
* DATEDIF
2019-11-21 02:21:00 +03:00
|
|
|
// commercial license can be purchased on https://unidoc.io.
|
2017-10-10 18:35:41 -04:00
|
|
|
|
2018-09-27 11:20:18 -05:00
|
|
|
package document
|
2017-10-10 18:35:41 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-05-04 11:18:06 +03:00
|
|
|
"github.com/unidoc/unioffice"
|
|
|
|
"github.com/unidoc/unioffice/schema/soo/ofc/sharedTypes"
|
|
|
|
"github.com/unidoc/unioffice/schema/soo/wml"
|
2017-10-10 18:35:41 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRunClear(t *testing.T) {
|
2018-09-27 11:20:18 -05:00
|
|
|
doc := New()
|
2017-10-10 18:35:41 -04:00
|
|
|
para := doc.AddParagraph()
|
|
|
|
run := para.AddRun()
|
|
|
|
if len(run.X().EG_RunInnerContent) != 0 {
|
|
|
|
t.Errorf("expected inner content of length zero, had %d", len(run.X().EG_RunInnerContent))
|
|
|
|
}
|
|
|
|
for i := 0; i < 5; i++ {
|
|
|
|
if i%2 == 0 {
|
|
|
|
run.AddText("test")
|
|
|
|
} else {
|
|
|
|
run.AddTab()
|
|
|
|
}
|
|
|
|
if len(run.X().EG_RunInnerContent) != i+1 {
|
|
|
|
t.Errorf("expected inner content of length %d, had %d", i+1, len(run.X().EG_RunInnerContent))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
run.Clear()
|
|
|
|
if len(run.X().EG_RunInnerContent) != 0 {
|
|
|
|
t.Errorf("expected inner content of length zero, had %d", len(run.X().EG_RunInnerContent))
|
|
|
|
}
|
|
|
|
}
|
2018-09-27 11:20:18 -05:00
|
|
|
|
|
|
|
// Issue #204
|
|
|
|
func TestRunPropertiesBold(t *testing.T) {
|
|
|
|
r := RunProperties{wml.NewCT_RPr()}
|
|
|
|
if r.IsBold() {
|
|
|
|
t.Errorf("expected IsBold = false with no bold element")
|
|
|
|
}
|
|
|
|
r.x.B = wml.NewCT_OnOff()
|
|
|
|
r.x.B.ValAttr = &sharedTypes.ST_OnOff{}
|
2019-05-04 13:54:29 +00:00
|
|
|
r.x.B.ValAttr.Bool = unioffice.Bool(false)
|
2018-09-27 11:20:18 -05:00
|
|
|
|
|
|
|
if r.IsBold() {
|
|
|
|
t.Errorf("expected IsBold = false with false bool value")
|
|
|
|
}
|
|
|
|
|
2019-05-04 13:54:29 +00:00
|
|
|
r.x.B.ValAttr.Bool = unioffice.Bool(true)
|
2018-09-27 11:20:18 -05:00
|
|
|
if !r.IsBold() {
|
|
|
|
t.Errorf("expected IsBold = true with true bool value")
|
|
|
|
}
|
|
|
|
|
|
|
|
r.x.B = wml.NewCT_OnOff()
|
|
|
|
if !r.IsBold() {
|
|
|
|
t.Errorf("expected IsBold = true with existence and no bool value")
|
|
|
|
}
|
|
|
|
}
|