mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
test text
This commit is contained in:
parent
f406f657c4
commit
f614c737f5
64
source/cell/tests/test_text.hpp
Normal file
64
source/cell/tests/test_text.hpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#pragma once
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include <xlnt/xlnt.hpp>
|
||||
|
||||
class test_text : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_operators()
|
||||
{
|
||||
xlnt::text text1;
|
||||
xlnt::text text2;
|
||||
TS_ASSERT_EQUALS(text1, text2);
|
||||
xlnt::text_run run_default;
|
||||
text1.add_run(run_default);
|
||||
TS_ASSERT_DIFFERS(text1, text2);
|
||||
text2.add_run(run_default);
|
||||
TS_ASSERT_EQUALS(text1, text2);
|
||||
|
||||
xlnt::text_run run_formatted;
|
||||
run_formatted.set_color("maroon");
|
||||
run_formatted.set_font("Cambria");
|
||||
run_formatted.set_scheme("ascheme");
|
||||
run_formatted.set_size(40);
|
||||
run_formatted.set_family(17);
|
||||
|
||||
xlnt::text text_formatted;
|
||||
text_formatted.add_run(run_formatted);
|
||||
|
||||
xlnt::text_run run_color_differs = run_formatted;
|
||||
run_color_differs.set_color("mauve");
|
||||
xlnt::text text_color_differs;
|
||||
text_color_differs.add_run(run_color_differs);
|
||||
TS_ASSERT_DIFFERS(text_formatted, text_color_differs);
|
||||
|
||||
xlnt::text_run run_font_differs = run_formatted;
|
||||
run_font_differs.set_font("Calibri");
|
||||
xlnt::text text_font_differs;
|
||||
text_font_differs.add_run(run_font_differs);
|
||||
TS_ASSERT_DIFFERS(text_formatted, text_font_differs);
|
||||
|
||||
xlnt::text_run run_scheme_differs = run_formatted;
|
||||
run_scheme_differs.set_scheme("bscheme");
|
||||
xlnt::text text_scheme_differs;
|
||||
text_scheme_differs.add_run(run_scheme_differs);
|
||||
TS_ASSERT_DIFFERS(text_formatted, text_scheme_differs);
|
||||
|
||||
xlnt::text_run run_size_differs = run_formatted;
|
||||
run_size_differs.set_size(41);
|
||||
xlnt::text text_size_differs;
|
||||
text_size_differs.add_run(run_size_differs);
|
||||
TS_ASSERT_DIFFERS(text_formatted, text_size_differs);
|
||||
|
||||
xlnt::text_run run_family_differs = run_formatted;
|
||||
run_family_differs.set_family(18);
|
||||
xlnt::text text_family_differs;
|
||||
text_family_differs.add_run(run_family_differs);
|
||||
TS_ASSERT_DIFFERS(text_formatted, text_family_differs);
|
||||
}
|
||||
};
|
|
@ -71,37 +71,37 @@ bool text::operator==(const text &rhs) const
|
|||
|
||||
if (runs_[i].has_formatting())
|
||||
{
|
||||
if (runs_[i].has_color() == rhs.runs_[i].has_color()
|
||||
&& runs_[i].has_color()
|
||||
&& runs_[i].get_color() != rhs.runs_[i].get_color())
|
||||
if (runs_[i].has_color() != rhs.runs_[i].has_color()
|
||||
|| (runs_[i].has_color()
|
||||
&& runs_[i].get_color() != rhs.runs_[i].get_color()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (runs_[i].has_family() == rhs.runs_[i].has_family()
|
||||
&& runs_[i].has_family()
|
||||
&& runs_[i].get_family() != rhs.runs_[i].get_family())
|
||||
if (runs_[i].has_family() != rhs.runs_[i].has_family()
|
||||
|| (runs_[i].has_family()
|
||||
&& runs_[i].get_family() != rhs.runs_[i].get_family()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (runs_[i].has_font() == rhs.runs_[i].has_font()
|
||||
&& runs_[i].has_font()
|
||||
&& runs_[i].get_font() != rhs.runs_[i].get_font())
|
||||
if (runs_[i].has_font() != rhs.runs_[i].has_font()
|
||||
|| (runs_[i].has_font()
|
||||
&& runs_[i].get_font() != rhs.runs_[i].get_font()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (runs_[i].has_scheme() == rhs.runs_[i].has_scheme()
|
||||
&& runs_[i].has_scheme()
|
||||
&& runs_[i].get_scheme() != rhs.runs_[i].get_scheme())
|
||||
if (runs_[i].has_scheme() != rhs.runs_[i].has_scheme()
|
||||
|| (runs_[i].has_scheme()
|
||||
&& runs_[i].get_scheme() != rhs.runs_[i].get_scheme()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (runs_[i].has_size() == rhs.runs_[i].has_size()
|
||||
&& runs_[i].has_size()
|
||||
&& runs_[i].get_size() != rhs.runs_[i].get_size())
|
||||
if (runs_[i].has_size() != rhs.runs_[i].has_size()
|
||||
|| (runs_[i].has_size()
|
||||
&& runs_[i].get_size() != rhs.runs_[i].get_size()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
xlnt::workbook wb;
|
||||
wb.get_app_properties().application = "Microsoft Excel";
|
||||
wb.get_app_properties().app_version = "12.0000";
|
||||
wb.get_app_properties().company = "Company";
|
||||
wb.create_sheet();
|
||||
wb.create_sheet();
|
||||
xlnt::workbook_serializer serializer(wb);
|
||||
|
|
|
@ -1003,7 +1003,12 @@ public:
|
|||
|
||||
TS_ASSERT(margins.is_default());
|
||||
|
||||
margins.set_top(0);
|
||||
margins.set_bottom(1);
|
||||
margins.set_header(2);
|
||||
margins.set_footer(3);
|
||||
margins.set_left(4);
|
||||
margins.set_right(5);
|
||||
TS_ASSERT(!margins.is_default());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version='1.0' ?>
|
||||
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><Company /><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>12.0000</AppVersion><HeadingPairs><vt:vector baseType="variant" size="2"><vt:variant><vt:lpstr>Worksheets</vt:lpstr></vt:variant><vt:variant><vt:i4>3</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector baseType="lpstr" size="3"><vt:lpstr>Sheet</vt:lpstr><vt:lpstr>Sheet1</vt:lpstr><vt:lpstr>Sheet2</vt:lpstr></vt:vector></TitlesOfParts></Properties>
|
||||
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><Company>Company</Company><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>12.0000</AppVersion><HeadingPairs><vt:vector baseType="variant" size="2"><vt:variant><vt:lpstr>Worksheets</vt:lpstr></vt:variant><vt:variant><vt:i4>3</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector baseType="lpstr" size="3"><vt:lpstr>Sheet</vt:lpstr><vt:lpstr>Sheet1</vt:lpstr><vt:lpstr>Sheet2</vt:lpstr></vt:vector></TitlesOfParts></Properties>
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version='1.0' ?>
|
||||
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><Company /><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>12.0000</AppVersion><HeadingPairs><vt:vector baseType="variant" size="2"><vt:variant><vt:lpstr>Worksheets</vt:lpstr></vt:variant><vt:variant><vt:i4>3</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector baseType="lpstr" size="3"><vt:lpstr>Sheet</vt:lpstr><vt:lpstr>Sheet1</vt:lpstr><vt:lpstr>Sheet2</vt:lpstr></vt:vector></TitlesOfParts></Properties>
|
||||
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><Company>Company</Company><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>12.0000</AppVersion><HeadingPairs><vt:vector baseType="variant" size="2"><vt:variant><vt:lpstr>Worksheets</vt:lpstr></vt:variant><vt:variant><vt:i4>3</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector baseType="lpstr" size="3"><vt:lpstr>Sheet</vt:lpstr><vt:lpstr>Sheet1</vt:lpstr><vt:lpstr>Sheet2</vt:lpstr></vt:vector></TitlesOfParts></Properties>
|
Loading…
Reference in New Issue
Block a user