From c63bad69910f1ae5f9e633e4d16e12c1ae8aaf30 Mon Sep 17 00:00:00 2001 From: Mingun Date: Thu, 11 Apr 2024 20:13:22 +0500 Subject: [PATCH] KST: Fix too small input file for `expr_io_ternary` test The test requires 1 + 4 + 8 = 13 bytes, but term_strz.bin contains only 12 bytes. Strange, but Ruby test was successfully passed. This commit replaces too small `term_strz.bin` file with `if_struct.bin` which size is 13 bytes. --- spec/construct/test_expr_io_ternary.py | 2 +- spec/cpp_stl_11/test_expr_io_ternary.cpp | 2 +- spec/cpp_stl_98/test_expr_io_ternary.cpp | 2 +- .../kaitai_struct_csharp_tests/tests/SpecExprIoTernary.cs | 2 +- spec/go/expr_io_ternary_test.go | 2 +- spec/java/src/io/kaitai/struct/spec/TestExprIoTernary.java | 2 +- spec/javascript/test_expr_io_ternary.js | 2 +- spec/ks/expr_io_ternary.kst | 2 +- spec/lua/test_expr_io_ternary.lua | 2 +- spec/nim/texpr_io_ternary.nim | 2 +- spec/perl/TestExprIoTernary.t | 2 +- spec/php/ExprIoTernaryTest.php | 2 +- spec/python/test_expr_io_ternary.py | 3 +-- spec/ruby/expr_io_ternary_spec.rb | 2 +- spec/rust/test_expr_io_ternary.rs | 2 +- 15 files changed, 15 insertions(+), 16 deletions(-) diff --git a/spec/construct/test_expr_io_ternary.py b/spec/construct/test_expr_io_ternary.py index e7b64ae41..e8f23d4ec 100644 --- a/spec/construct/test_expr_io_ternary.py +++ b/spec/construct/test_expr_io_ternary.py @@ -6,7 +6,7 @@ class TestExprIoTernary(unittest.TestCase): def test_expr_io_ternary(self): - r = _schema.parse_file('src/term_strz.bin') + r = _schema.parse_file('src/if_struct.bin') self.assertEqual(r.one_or_two_io_size1, 8) self.assertEqual(r.one_or_two_io_size2, 8) diff --git a/spec/cpp_stl_11/test_expr_io_ternary.cpp b/spec/cpp_stl_11/test_expr_io_ternary.cpp index 2f8164ec5..40b4c82b1 100644 --- a/spec/cpp_stl_11/test_expr_io_ternary.cpp +++ b/spec/cpp_stl_11/test_expr_io_ternary.cpp @@ -7,7 +7,7 @@ #include BOOST_AUTO_TEST_CASE(test_expr_io_ternary) { - std::ifstream ifs("src/term_strz.bin", std::ifstream::binary); + std::ifstream ifs("src/if_struct.bin", std::ifstream::binary); kaitai::kstream ks(&ifs); expr_io_ternary_t* r = new expr_io_ternary_t(&ks); diff --git a/spec/cpp_stl_98/test_expr_io_ternary.cpp b/spec/cpp_stl_98/test_expr_io_ternary.cpp index 2f8164ec5..40b4c82b1 100644 --- a/spec/cpp_stl_98/test_expr_io_ternary.cpp +++ b/spec/cpp_stl_98/test_expr_io_ternary.cpp @@ -7,7 +7,7 @@ #include BOOST_AUTO_TEST_CASE(test_expr_io_ternary) { - std::ifstream ifs("src/term_strz.bin", std::ifstream::binary); + std::ifstream ifs("src/if_struct.bin", std::ifstream::binary); kaitai::kstream ks(&ifs); expr_io_ternary_t* r = new expr_io_ternary_t(&ks); diff --git a/spec/csharp/kaitai_struct_csharp_tests/tests/SpecExprIoTernary.cs b/spec/csharp/kaitai_struct_csharp_tests/tests/SpecExprIoTernary.cs index 7c0e82273..9b681cee3 100644 --- a/spec/csharp/kaitai_struct_csharp_tests/tests/SpecExprIoTernary.cs +++ b/spec/csharp/kaitai_struct_csharp_tests/tests/SpecExprIoTernary.cs @@ -10,7 +10,7 @@ public class SpecExprIoTernary : CommonSpec [Test] public void TestExprIoTernary() { - var r = ExprIoTernary.FromFile(SourceFile("term_strz.bin")); + var r = ExprIoTernary.FromFile(SourceFile("if_struct.bin")); Assert.AreEqual(r.OneOrTwoIoSize1, 8); Assert.AreEqual(r.OneOrTwoIoSize2, 8); diff --git a/spec/go/expr_io_ternary_test.go b/spec/go/expr_io_ternary_test.go index 537d9e7c3..19ae32869 100644 --- a/spec/go/expr_io_ternary_test.go +++ b/spec/go/expr_io_ternary_test.go @@ -18,7 +18,7 @@ func TestExprIoTernary(t *testing.T) { t.Fatal("unexpected panic:", r) } }() - f, err := os.Open("../../src/term_strz.bin") + f, err := os.Open("../../src/if_struct.bin") if err != nil { t.Fatal(err) } diff --git a/spec/java/src/io/kaitai/struct/spec/TestExprIoTernary.java b/spec/java/src/io/kaitai/struct/spec/TestExprIoTernary.java index 4827705b9..9c51f6d44 100644 --- a/spec/java/src/io/kaitai/struct/spec/TestExprIoTernary.java +++ b/spec/java/src/io/kaitai/struct/spec/TestExprIoTernary.java @@ -9,7 +9,7 @@ public class TestExprIoTernary extends CommonSpec { @Test public void testExprIoTernary() throws Exception { - ExprIoTernary r = ExprIoTernary.fromFile(SRC_DIR + "term_strz.bin"); + ExprIoTernary r = ExprIoTernary.fromFile(SRC_DIR + "if_struct.bin"); assertIntEquals(r.oneOrTwoIoSize1(), 8); assertIntEquals(r.oneOrTwoIoSize2(), 8); diff --git a/spec/javascript/test_expr_io_ternary.js b/spec/javascript/test_expr_io_ternary.js index 990d91e44..3c32308a6 100644 --- a/spec/javascript/test_expr_io_ternary.js +++ b/spec/javascript/test_expr_io_ternary.js @@ -3,7 +3,7 @@ var assert = require('assert'); var testHelper = require('testHelper'); -testHelper('ExprIoTernary', 'src/term_strz.bin', function(r, ExprIoTernary) { +testHelper('ExprIoTernary', 'src/if_struct.bin', function(r, ExprIoTernary) { assert.strictEqual(r.oneOrTwoIoSize1, 8); assert.strictEqual(r.oneOrTwoIoSize2, 8); diff --git a/spec/ks/expr_io_ternary.kst b/spec/ks/expr_io_ternary.kst index 3dc2311e6..c4e31cf7f 100644 --- a/spec/ks/expr_io_ternary.kst +++ b/spec/ks/expr_io_ternary.kst @@ -1,5 +1,5 @@ id: expr_io_ternary -data: term_strz.bin +data: if_struct.bin asserts: - actual: one_or_two_io_size1 expected: 8 diff --git a/spec/lua/test_expr_io_ternary.lua b/spec/lua/test_expr_io_ternary.lua index 5da510a33..ba850fa60 100644 --- a/spec/lua/test_expr_io_ternary.lua +++ b/spec/lua/test_expr_io_ternary.lua @@ -7,7 +7,7 @@ require("expr_io_ternary") TestExprIoTernary = {} function TestExprIoTernary:test_expr_io_ternary() - local r = ExprIoTernary:from_file("src/term_strz.bin") + local r = ExprIoTernary:from_file("src/if_struct.bin") luaunit.assertEquals(r.one_or_two_io_size1, 8) luaunit.assertEquals(r.one_or_two_io_size2, 8) diff --git a/spec/nim/texpr_io_ternary.nim b/spec/nim/texpr_io_ternary.nim index 7b9b845ef..85632b22c 100644 --- a/spec/nim/texpr_io_ternary.nim +++ b/spec/nim/texpr_io_ternary.nim @@ -4,7 +4,7 @@ import os, streams, options, sequtils import ../../compiled/nim/expr_io_ternary import auxiliary/test_utils -let r = ExprIoTernary.fromFile("../../src/term_strz.bin") +let r = ExprIoTernary.fromFile("../../src/if_struct.bin") assert r.oneOrTwoIoSize1 == 8 assert r.oneOrTwoIoSize2 == 8 diff --git a/spec/perl/TestExprIoTernary.t b/spec/perl/TestExprIoTernary.t index 4a920a643..29fe4cdec 100644 --- a/spec/perl/TestExprIoTernary.t +++ b/spec/perl/TestExprIoTernary.t @@ -9,7 +9,7 @@ use Test::More; use ExprIoTernary; sub test_expr_io_ternary: Test(3) { - my $r = ExprIoTernary->from_file('src/term_strz.bin'); + my $r = ExprIoTernary->from_file('src/if_struct.bin'); is($r->one_or_two_io_size1(), 8, 'Equals'); is($r->one_or_two_io_size2(), 8, 'Equals'); diff --git a/spec/php/ExprIoTernaryTest.php b/spec/php/ExprIoTernaryTest.php index 93700f4c3..4d372ff89 100644 --- a/spec/php/ExprIoTernaryTest.php +++ b/spec/php/ExprIoTernaryTest.php @@ -5,7 +5,7 @@ class ExprIoTernaryTest extends TestCase { public function testExprIoTernary() { - $r = ExprIoTernary::fromFile(self::SRC_DIR_PATH . '/term_strz.bin'); + $r = ExprIoTernary::fromFile(self::SRC_DIR_PATH . '/if_struct.bin'); $this->assertSame(8, $r->oneOrTwoIoSize1()); $this->assertSame(8, $r->oneOrTwoIoSize2()); diff --git a/spec/python/test_expr_io_ternary.py b/spec/python/test_expr_io_ternary.py index 3d6627d68..dc51baf0e 100644 --- a/spec/python/test_expr_io_ternary.py +++ b/spec/python/test_expr_io_ternary.py @@ -1,12 +1,11 @@ # Autogenerated from KST: please remove this line if doing any edits by hand! import unittest - from expr_io_ternary import ExprIoTernary class TestExprIoTernary(unittest.TestCase): def test_expr_io_ternary(self): - with ExprIoTernary.from_file('src/term_strz.bin') as r: + with ExprIoTernary.from_file('src/if_struct.bin') as r: self.assertEqual(r.one_or_two_io_size1, 8) self.assertEqual(r.one_or_two_io_size2, 8) diff --git a/spec/ruby/expr_io_ternary_spec.rb b/spec/ruby/expr_io_ternary_spec.rb index dd10d0962..bfd70ed5e 100644 --- a/spec/ruby/expr_io_ternary_spec.rb +++ b/spec/ruby/expr_io_ternary_spec.rb @@ -3,7 +3,7 @@ RSpec.describe 'ExprIoTernary' do it 'parses test properly' do require 'expr_io_ternary' - r = ExprIoTernary.from_file('src/term_strz.bin') + r = ExprIoTernary.from_file('src/if_struct.bin') expect(r.one_or_two_io_size1).to eq 8 expect(r.one_or_two_io_size2).to eq 8 diff --git a/spec/rust/test_expr_io_ternary.rs b/spec/rust/test_expr_io_ternary.rs index 60bf037c3..5fc6c9715 100644 --- a/spec/rust/test_expr_io_ternary.rs +++ b/spec/rust/test_expr_io_ternary.rs @@ -8,7 +8,7 @@ use rust::ExprIoTernary; #[test] fn test_expr_io_ternary() { - if let Ok(r) = ExprIoTernary::from_file("src/term_strz.bin") { + if let Ok(r) = ExprIoTernary::from_file("src/if_struct.bin") { assert_eq!(r.one_or_two_io_size1, 8); assert_eq!(r.one_or_two_io_size2, 8);