Skip to content

Commit

Permalink
fix tc_json double bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Aug 29, 2023
1 parent 79bfb48 commit 56af488
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions unit-test/server/Hello.tars
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ module Test
0 optional map<JsonKey, JsonData> json;
};

struct JsonDouble
{
1 optional double d;
};

interface Hello
{
int testTrans(int index, string s, out string r);
Expand Down
13 changes: 13 additions & 0 deletions unit-test/util/test_tc_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,16 @@ TEST_F(JsonTest, find)
ASSERT_TRUE(aPtr->find(new JsonValueBoolean(false)) != aPtr->value.end());
// ASSERT_TRUE(aPtr->find(new JsonValueBoolean(true)) != aPtr->value.end());
}

TEST_F(JsonTest, jsonDouble)
{
JsonDouble jValue;
jValue.d = 1.32e1;
string v = jValue.writeToJsonString();

cout << "json1:" << v << endl;
v = "{\"d\":1.32e1}";

jValue.readFromJsonString(v);
cout << jValue.d << endl;
}
1 change: 1 addition & 0 deletions util/src/tc_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ JsonValueNumPtr TC_Json::getNum(BufferJsonReader & reader,char head)
{
bOk=true;
bExponential=(bool)(c-0x30);
iExponential=c-0x30;
}
else
{
Expand Down

0 comments on commit 56af488

Please sign in to comment.