summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/tests')
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/tests/BezierTest.cpp2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/tests/CRC32Test.cpp7
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/tests/ToUnicodeMapTest.cpp29
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/tests/UnicodeTest.cpp10
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/tests/VectorIteratorTest.cpp8
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/tests/XMLNodeTest.cpp14
-rwxr-xr-xBuild/source/texk/dvisvgm/dvisvgm-src/tests/genhashcheck.py94
7 files changed, 85 insertions, 79 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/BezierTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/BezierTest.cpp
index 26ba7f98666..550ea2b94fe 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/BezierTest.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/BezierTest.cpp
@@ -128,7 +128,7 @@ TEST(BezierTest, approximate) {
EXPECT_EQ(points.size(), size);
EXPECT_EQ(times.size(), size);
for (int i=0; i < size; i++) {
- EXPECT_EQ(times[i], t[i]);
+ EXPECT_EQ(times[i], t[i]) << "i=" << i;
EXPECT_PAIR_NEAR(points[i], p[i]);
}
}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/CRC32Test.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/CRC32Test.cpp
index 44a0758d255..c6033344655 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/CRC32Test.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/CRC32Test.cpp
@@ -37,7 +37,7 @@ TEST(CRC32Test, update_numbers) {
const uint32_t comp[]={0xf8923be6, 0x4dcd2866, 0x4fdbb57a, 0xcb40f3bf, 0xf1a33887, 0x3422c816, 0x3a8b92a4, 0xedafc4ce, 0x4f5d17ec, 0x4a9f2f68};
for (int i=-5; i < 5; ++i) {
crc.update(i);
- EXPECT_EQ(crc.get(), comp[i+5]);
+ EXPECT_EQ(crc.get(), comp[i+5]) << "i=" << i;
}
crc.reset();
EXPECT_EQ(crc.get(), 0);
@@ -73,7 +73,6 @@ TEST(CRC32Test, update_string) {
TEST(CRC32Test, compute) {
EXPECT_EQ(CRC32::compute("dvisvgm converts DVI files to SVG."), 0x7c4ef359);
- istringstream iss;
- iss.str("It is published under the GNU General Public License.");
+ istringstream iss("It is published under the GNU General Public License.");
EXPECT_EQ(CRC32::compute(iss), 0xbc02ba40);
-} \ No newline at end of file
+}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/ToUnicodeMapTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/ToUnicodeMapTest.cpp
index 8d04483d393..29ffc6f2684 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/ToUnicodeMapTest.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/ToUnicodeMapTest.cpp
@@ -19,23 +19,25 @@
*************************************************************************/
#include <gtest/gtest.h>
+#include <sstream>
+#include <string>
#include "ToUnicodeMap.hpp"
using namespace std;
+#define CHECK_RANGE(ucmap, min, max, minval) check_range(ucmap, min, max, minval, __LINE__)
-static void check_range (const ToUnicodeMap &ucmap, int min, int max, int minval) {
- for (int i=min; i <= max; i++)
- ASSERT_EQ(ucmap.valueAt(i), minval+(i-min));
+static void check_range (const ToUnicodeMap &ucmap, uint32_t min, uint32_t max, uint32_t minval, int line) {
+ for (uint32_t i=min; i <= max; i++)
+ ASSERT_EQ(ucmap.valueAt(i), minval+(i-min)) << __FILE__ << ":" << line << ": i=" << i;
}
TEST(ToUnicodeMapTest, addMissingMappings1) {
ToUnicodeMap ucmap;
- bool success = ucmap.addMissingMappings(20);
- ASSERT_TRUE(success);
+ ASSERT_TRUE(ucmap.addMissingMappings(20));
ASSERT_EQ(ucmap.size(), 1);
- check_range(ucmap, 1, 20, 1);
+ CHECK_RANGE(ucmap, 1, 20, 1);
}
@@ -43,18 +45,15 @@ TEST(ToUnicodeMapTest, addMissingMappings2) {
ToUnicodeMap ucmap;
ucmap.addRange(5, 8, 40);
ASSERT_EQ(ucmap.size(), 1);
- check_range(ucmap, 5, 8, 40);
+ CHECK_RANGE(ucmap, 5, 8, 40);
ucmap.addRange(10, 15, 50);
ASSERT_EQ(ucmap.size(), 2);
- check_range(ucmap, 5, 8, 40);
- check_range(ucmap, 10, 15, 50);
+ CHECK_RANGE(ucmap, 5, 8, 40);
+ CHECK_RANGE(ucmap, 10, 15, 50);
- bool success = ucmap.addMissingMappings(20);
- ASSERT_TRUE(success);
+ ASSERT_TRUE(ucmap.addMissingMappings(20));
ASSERT_EQ(ucmap.size(), 2);
- check_range(ucmap, 1, 9, 36);
- check_range(ucmap, 10, 20, 50);
+ CHECK_RANGE(ucmap, 1, 9, 36);
+ CHECK_RANGE(ucmap, 10, 20, 50);
}
-
-
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/UnicodeTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/UnicodeTest.cpp
index ec7ec07caec..addf349101a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/UnicodeTest.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/UnicodeTest.cpp
@@ -26,9 +26,9 @@ using namespace std;
TEST(UnicodeTest, isValidCodepoint) {
for (uint32_t i=0; i <= 0x20; i++)
- EXPECT_FALSE(Unicode::isValidCodepoint(i));
+ EXPECT_FALSE(Unicode::isValidCodepoint(i)) << "i=" << i;
for (uint32_t i=0x21; i <= 0x7e; i++)
- EXPECT_TRUE(Unicode::isValidCodepoint(i));
+ EXPECT_TRUE(Unicode::isValidCodepoint(i)) << "i=" << i;
EXPECT_FALSE(Unicode::isValidCodepoint(0xfffe));
EXPECT_FALSE(Unicode::isValidCodepoint(0xffff));
EXPECT_TRUE(Unicode::isValidCodepoint(0x10000));
@@ -37,11 +37,11 @@ TEST(UnicodeTest, isValidCodepoint) {
TEST(UnicodeTest, charToCodepoint) {
for (uint32_t i=0; i <= 0x20; i++)
- EXPECT_EQ(Unicode::charToCodepoint(i), 0xe000+i);
+ EXPECT_EQ(Unicode::charToCodepoint(i), 0xe000+i) << "i=" << i;
for (uint32_t i=0x21; i <= 0x7e; i++)
- EXPECT_EQ(Unicode::charToCodepoint(i), i);
+ EXPECT_EQ(Unicode::charToCodepoint(i), i) << "i=" << i;
for (uint32_t i=0x7f; i <= 0x9f; i++)
- EXPECT_EQ(Unicode::charToCodepoint(i), 0xe021+i-0x7f);
+ EXPECT_EQ(Unicode::charToCodepoint(i), 0xe021+i-0x7f) << "i=" << i;
EXPECT_EQ(Unicode::charToCodepoint(0x10fffd), 0x10fffd);
EXPECT_EQ(Unicode::charToCodepoint(0x10fffe), 0xe887);
EXPECT_EQ(Unicode::charToCodepoint(0x10ffff), 0xe888);
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/VectorIteratorTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/VectorIteratorTest.cpp
index a043c86bc9b..8febc5479dc 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/VectorIteratorTest.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/VectorIteratorTest.cpp
@@ -33,8 +33,8 @@ TEST(VectorIteratorTest, inc) {
EXPECT_EQ(*++it, 2);
EXPECT_TRUE(it.valid());
for (int i=2; it.valid(); i++) {
- EXPECT_LT(i, vec.size());
- EXPECT_EQ(*it, vec[i]);
+ EXPECT_LT(i, vec.size()) << "i=" << i;
+ EXPECT_EQ(*it, vec[i]) << "*it=" << *it << ", vec[" << i << "]=" << vec[i];
++it;
}
}
@@ -60,8 +60,8 @@ TEST(VectorIteratorTest, dec) {
EXPECT_EQ(*--it, 8);
EXPECT_TRUE(it.valid());
for (int i=4; it.valid(); i--) {
- EXPECT_LT(i, vec.size());
- EXPECT_EQ(*it, vec[i]);
+ EXPECT_LT(i, vec.size()) << "i=" << i;
+ EXPECT_EQ(*it, vec[i]) << "*it=" << *it << ", vec[" << i << "]=" << vec[i];
--it;
}
}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/XMLNodeTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/XMLNodeTest.cpp
index 36d9519f905..426075f5811 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/XMLNodeTest.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/XMLNodeTest.cpp
@@ -165,8 +165,11 @@ TEST(XMLNodeTest, insertBefore) {
EXPECT_TRUE(root.insertBefore(new XMLElementNode("child4"), child2));
const char *names[] = {"child3", "child1", "child4", "child2"};
const char **p = names;
- for (const auto &node : root.children())
- EXPECT_EQ(dynamic_cast<XMLElementNode*>(node.get())->getName(), *p++);
+ for (const auto &node : root.children()) {
+ XMLElementNode *elem = dynamic_cast<XMLElementNode*>(node.get());
+ ASSERT_NE(elem, nullptr);
+ EXPECT_EQ(elem->getName(), *p++) << "name=" << elem->getName();
+ }
}
@@ -185,8 +188,11 @@ TEST(XMLNodeTest, insertAfter) {
EXPECT_EQ(root.children().size(), 4);
const char *names[] = {"child1", "child3", "child2", "child4"};
const char **p = names;
- for (const auto &node : root.children())
- EXPECT_EQ(dynamic_cast<XMLElementNode*>(node.get())->getName(), *p++);
+ for (const auto &node : root.children()) {
+ XMLElementNode *elem = dynamic_cast<XMLElementNode*>(node.get());
+ ASSERT_NE(elem, nullptr);
+ EXPECT_EQ(elem->getName(), *p++) << "name=" << elem->getName();
+ }
}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/genhashcheck.py b/Build/source/texk/dvisvgm/dvisvgm-src/tests/genhashcheck.py
index bc93ef064f5..d53ad22938e 100755
--- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/genhashcheck.py
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/genhashcheck.py
@@ -8,24 +8,27 @@ import re
import sys
def extract_hashes (fname):
- with open(fname) as f:
- lines = f.readlines()
- found = False
- for line in lines:
- if ' hash2unicode = {{\n' in line:
- found = True
- elif found:
- match = re.search(r'^\s*{(0x[0-9a-f]{8}),\s*0x[0-9a-f]{4}}, //\s*(.+)\s*$', line)
- if match:
- print '\t{%s, "%s"},' % (match.group(1), match.group(2))
- else:
- found = False
+ with open(fname) as f:
+ lines = f.readlines()
+ found = False
+ for line in lines:
+ if ' hash2unicode = {{\n' in line:
+ found = True
+ elif found:
+ match = re.match(r'\s*{(0x[0-9a-f]{8}),\s*0x[0-9a-f]{4}}, //\s*(.+)\s*$', line)
+ if match:
+ hashval = match.group(1)
+ name = match.group(2)
+ print('\t{}{}, "{}"{},'.format('{', hashval, name, '}'))
+ else:
+ found = False
if (len(sys.argv) < 2):
- sys.exit(1)
+ sys.exit(1)
-print """\
+print("""\
#include <xxhash.h>
+#include <cstdint>
#include <iomanip>
#include <iostream>
#include <string>
@@ -33,39 +36,38 @@ print """\
using namespace std;
struct NameHash {
- unsigned hash;
- string name;
-} nameHashes[] = {
-"""
+ uint32_t hash;
+ string name;
+} nameHashes[] = {\
+""")
extract_hashes(sys.argv[1])
-print """\
-};
+print(r"""};
int main () {
- unsigned prev_hash=0;
- size_t size = sizeof(nameHashes)/sizeof(NameHash);
- if (size == 0) {
- cout << "hash table is empty\\n";
- return 1;
- }
- for (unsigned i=0; i < size; i++) {
- const string &name = nameHashes[i].name;
- const unsigned hash = nameHashes[i].hash;
- if (XXH32(&name[0], name.length(), 0) != hash) {
- cout << "hash of '" << name << "' doesn't match\\n";
- return 1;
- }
- if (hash < prev_hash) {
- cout << "misplaced hash value " << hex << setw(8) << setfill('0') << hash << "\\n";
- return 1;
- }
- if (hash == prev_hash) {
- cout << "colliding hash values " << hex << setw(8) << setfill('0') << hash << "\\n";
- return 1;
- }
- prev_hash = hash;
- }
- cout << "hash check passed\\n";
- return 0;
+ uint32_t prev_hash=0;
+ size_t size = sizeof(nameHashes)/sizeof(NameHash);
+ if (size == 0) {
+ cout << "hash table is empty\n";
+ return 1;
+ }
+ for (size_t i=0; i < size; i++) {
+ const string &name = nameHashes[i].name;
+ const uint32_t hash = nameHashes[i].hash;
+ if (XXH32(&name[0], name.length(), 0) != hash) {
+ cout << "hash of '" << name << "' doesn't match\n";
+ return 1;
+ }
+ if (hash < prev_hash) {
+ cout << "misplaced hash value " << hex << setw(8) << setfill('0') << hash << "\n";
+ return 1;
+ }
+ if (hash == prev_hash) {
+ cout << "colliding hash values " << hex << setw(8) << setfill('0') << hash << "\n";
+ return 1;
+ }
+ prev_hash = hash;
+ }
+ cout << "hash check passed\n";
+ return 0;
}
-"""
+""")