Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee123a9

Browse files
committed
more ports of tests to AbsDiff
1 parentabf7926 commitee123a9

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎src/jumandic/shared/jumandic_codegen_test.cc‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
usingnamespacejumanpp::core;
1717
usingnamespacejumanpp;
1818

19+
using Catch::Matchers::WithinAbs;
20+
1921
namespace {
2022

2123
voiddumpJumandicLattice(std::string dst,
@@ -107,7 +109,7 @@ TEST_CASE(
107109
analysis::EntryBeam::isFake(be2)) {
108110
continue;
109111
}
110-
CHECK(be1.totalScore ==Approx(be2.totalScore));
112+
CHECK_THAT(be1.totalScore,WithinAbs(be2.totalScore, 1e-3f));
111113
}
112114
}
113115
}
@@ -118,7 +120,7 @@ TEST_CASE(
118120

119121
for (int i =0; i < tenv.beamSize; ++i) {
120122
CAPTURE(i);
121-
CHECK(lbeam1.at(i).totalScore ==Approx(lbeam2.at(i).totalScore));
123+
CHECK_THAT(lbeam1.at(i).totalScore,WithinAbs(lbeam2.at(i).totalScore, 1e-3f));
122124
}
123125
}
124126

@@ -196,7 +198,7 @@ TEST_CASE(
196198

197199
for (int el =0; el < nels; ++el) {
198200
CAPTURE(el);
199-
CHECK(t0s1.at(el) ==Approx(t0s2.at(el)));
201+
CHECK_THAT(t0s1.at(el),WithinAbs(t0s2.at(el), 1e-3f));
200202
}
201203
auto t1x1 = fb1.t1Buf(gen.ngramStats().num2Grams, nels);
202204
auto t1x2 = fb2.t1Buf(gen.ngramStats().num2Grams, nels);
@@ -232,7 +234,7 @@ TEST_CASE(
232234
auto t1s2 = proc2.scores_.bufferT1();
233235
for (int el =0; el < nels; ++el) {
234236
CAPTURE(el);
235-
CHECK(t1s1.at(el) ==Approx(t1s2.at(el)));
237+
CHECK_THAT(t1s1.at(el),WithinAbs(t1s2.at(el), 1e-3f));
236238
}
237239
proc1.resolveBeamAt(t1node.boundary, t1node.position);
238240
proc2.resolveBeamAt(t1node.boundary, t1node.position);
@@ -247,7 +249,7 @@ TEST_CASE(
247249
auto t2s2 = proc1.scores_.bufferT2();
248250
for (int el =0; el < nels; ++el) {
249251
CAPTURE(el);
250-
CHECK(t2s1.at(el) ==Approx(t2s2.at(el)));
252+
CHECK_THAT(t2s1.at(el),WithinAbs(t2s2.at(el), 1e-3f));
251253
}
252254
}
253255
}
@@ -337,7 +339,7 @@ TEST_CASE("feature representation of gen/nongen is the same with global beam") {
337339
}
338340

339341
CAPTURE(beam);
340-
CHECK(be1.totalScore ==Approx(be2.totalScore));
342+
CHECK_THAT(be1.totalScore,WithinAbs(be2.totalScore, 1e-3f));
341343
CHECK(be1.ptr == be2.ptr);
342344
}
343345
}
@@ -349,7 +351,7 @@ TEST_CASE("feature representation of gen/nongen is the same with global beam") {
349351

350352
for (int i =0; i < tenv.beamSize; ++i) {
351353
CAPTURE(i);
352-
CHECK(lbeam1.at(i).totalScore ==Approx(lbeam2.at(i).totalScore));
354+
CHECK_THAT(lbeam1.at(i).totalScore,WithinAbs(lbeam2.at(i).totalScore, 1e-3f));
353355
// LOG_WARN() << lbeam1.at(i).totalScore;
354356
// LOG_WARN() << lbeam2.at(i).totalScore;
355357
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp