1 Star 0 Fork 0

butnet/unioffice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
xml_test.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
Vyacheslav Zgordan 提交于 2019-11-21 02:21 . Functions2 (#348)
// Copyright 2017 FoxyUtils ehf. All rights reserved.
//
// 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
// commercial license can be purchased on https://unidoc.io.
package unioffice_test
import (
"encoding/xml"
"testing"
"github.com/unidoc/unioffice"
)
func TestAddPreserveSpaceAttr(t *testing.T) {
td := []struct {
Input string
HasAttr bool
}{
{"", false},
{"foo", false},
{"f o o", false},
{"foo ", true},
{" foo ", true},
{" foo ", true},
{"\tfoo", true},
{"\nfoo", true},
}
for _, tc := range td {
se := &xml.StartElement{}
unioffice.AddPreserveSpaceAttr(se, tc.Input)
if tc.HasAttr && len(se.Attr) == 0 {
t.Errorf("expected a preserve space attribute for %s", tc.Input)
} else if !tc.HasAttr && len(se.Attr) != 0 {
t.Errorf("expected no preserve space attribute for %s", tc.Input)
}
if tc.HasAttr {
if se.Attr[0].Name.Local != "xml:space" {
t.Errorf("expected name = xml:space, got %s", se.Attr[0].Name.Local)
}
if se.Attr[0].Value != "preserve" {
t.Errorf("expected name = preserve, got %s", se.Attr[0].Value)
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/butnet/unioffice.git
[email protected]:butnet/unioffice.git
butnet
unioffice
unioffice
master

搜索帮助