diff --git a/.gitignore b/.gitignore index 49093ba..64c1aa3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ _deps wasm/test_page/node_modules build-wasm models -wasm/test_page/bergamot-translator-worker.* +wasm/test_page/js/bergamot-translator-worker.* # VSCode .vscode diff --git a/bergamot-translator-tests b/bergamot-translator-tests index 332e976..b46987e 160000 --- a/bergamot-translator-tests +++ b/bergamot-translator-tests @@ -1 +1 @@ -Subproject commit 332e976df4583793a09b6483b80b972621fcfadb +Subproject commit b46987e96fc27b7e9488fbc36b53c07e1786784c diff --git a/src/tests/units/html_tests.cpp b/src/tests/units/html_tests.cpp index 48af706..d1a604d 100644 --- a/src/tests/units/html_tests.cpp +++ b/src/tests/units/html_tests.cpp @@ -169,24 +169,136 @@ TEST_CASE("Test case html entities") { // These are all entities I would expect in innerHTML, since all other entities // can be encoded as UTF-8 so there's no need to encode them through &...; when // innerHTML encodes the DOM as HTML. - std::string input("
This is a sentence <with> named & entities
\n"); + std::string input("This is a sentence <with> named & entities
"); HTML html(std::move(input), true); - CHECK(input == "This is a sentenceSpace
please?
Space
please?
Space
please?
Platz
bitte?
hello world
\n"); HTML html(std::move(input), true); - CHECK(input == "hello world\n"); + CHECK(input == "hello world\n\n\n"); // tripple \n because \n + - AnnotatedText source("hello world\n"); + AnnotatedText source("hello world\n\n\n"); recordSentenceFromByteRange(source, { ByteRange{0, 4}, // 0.0 "hell" ByteRange{4, 5}, // 0.1 "o" @@ -194,7 +306,7 @@ TEST_CASE("Test reconstruction of target sentence") { ByteRange{11, 11} // 0.3 "" }); - AnnotatedText target("hallo Welt\n"); + AnnotatedText target("hallo Welt\n\n\n"); recordSentenceFromByteRange(target, { ByteRange{0, 4}, // 0.0 "hall" ByteRange{4, 5}, // 0.1 "o" @@ -218,11 +330,11 @@ TEST_CASE("Test reconstruction of target sentence") { } TEST_CASE("Test reconstruction of target sentence with entities") { - std::string input("hello world & friends!
\n"); + std::string input("hello world & friends!
"); HTML html(std::move(input), true); - CHECK(input == "hello world & friends!\n"); + CHECK(input == "hello world & friends!"); - AnnotatedText source("hello world & friends!\n"); + AnnotatedText source("hello world & friends!"); recordSentenceFromByteRange(source, { ByteRange{0, 4}, // 0.0 "hell" ByteRange{4, 5}, // 0.1 "o" @@ -233,7 +345,7 @@ TEST_CASE("Test reconstruction of target sentence with entities") { ByteRange{22, 22} // 0.6 "" }); - AnnotatedText target("hallo Welt & Freunde!\n"); + AnnotatedText target("hallo Welt & Freunde!"); recordSentenceFromByteRange(target, { ByteRange{0, 4}, // 0.0 "hall" ByteRange{4, 5}, // 0.1 "o" @@ -252,11 +364,11 @@ TEST_CASE("Test reconstruction of target sentence with entities") { html.restore(response); std::vectorhell", "o", " world", " &", - " friends", "!", "", "
\n"}; + " friends", "!", "", ""}; - std::vectorhall", "o", " Welt", " &",
+ std::vector hall", "o", " Welt", " &",
- " Freunde", "!", "", "
hello world! How does this deal with multiple sentences? Will it work?
hello world! How does this deal with multiple sentences? Will it work?
hello world and other creatures
hello world and other creatures
hello world