Skip to content

Commit

Permalink
Fix to_i conversion for C++ that was changed in 0acd030
Browse files Browse the repository at this point in the history
Fixes

[info] - cpp_stl:"12345".to_i *** FAILED ***
[info]   "[kaitai::kstream::string_to_int](std::string("12345"..." was not equal to "[std::stoi](std::string("12345"..." (TranslatorSpec.scala:520)
[info]   Analysis:
[info]   "[kaitai::kstream::string_to_int](std::string("12345"..." -> "[std::stoi](std::string("12345"..."
[info] - cpp_stl:"1234fe".to_i(16) *** FAILED ***
[info]   "[kaitai::kstream::string_to_int(std::string("1234fe")], 16)" was not equal to "[std::stoi(std::string("1234fe"), 0], 16)" (TranslatorSpec.scala:533)
[info]   Analysis:
[info]   "[kaitai::kstream::string_to_int(std::string("1234fe")], 16)" -> "[std::stoi(std::string("1234fe"), 0], 16)"
  • Loading branch information
Mingun committed Mar 8, 2024
1 parent 25e3a58 commit 883ff24
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ class TranslatorSpec extends AnyFunSuite {
))

full("\"12345\".to_i", CalcIntType, CalcIntType, Map[LanguageCompilerStatic, String](
CppCompiler -> "std::stoi(std::string(\"12345\"))",
CppCompiler -> "kaitai::kstream::string_to_int(std::string(\"12345\"))",
CSharpCompiler -> "Convert.ToInt64(\"12345\", 10)",
GoCompiler -> "func()(int){i, err := strconv.Atoi(\"12345\"); if (err != nil) { panic(err) }; return i}()",
JavaCompiler -> "Long.parseLong(\"12345\", 10)",
Expand All @@ -531,7 +531,7 @@ class TranslatorSpec extends AnyFunSuite {
))

full("\"1234fe\".to_i(16)", CalcIntType, CalcIntType, Map[LanguageCompilerStatic, String](
CppCompiler -> "std::stoi(std::string(\"1234fe\"), 0, 16)",
CppCompiler -> "kaitai::kstream::string_to_int(std::string(\"1234fe\"), 16)",
CSharpCompiler -> "Convert.ToInt64(\"1234fe\", 16)",
GoCompiler -> "func()(int64){i, err := strconv.ParseInt(\"1234fe\", 16, 64); if (err != nil) { panic(err) }; return i}()",
JavaCompiler -> "Long.parseLong(\"1234fe\", 16)",
Expand Down

0 comments on commit 883ff24

Please sign in to comment.