diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-05-24 13:57:37 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-05-25 12:50:18 +0000 |
commit | a1e5a157802428cee7c01ada4def7c818ebfea82 (patch) | |
tree | b703766bb623d9981c8659fe9d62f32559fe1abb /test | |
parent | b078310bd0daf7cf8ba6df765cba9fcd98713dd8 (diff) |
wslua: fix NSTime:__tostring for negative values
"nstime_t{A, B}" is defined as "A + B * 10^9" rather than an integer
part A and fractional part B.
Bug: 14720
Change-Id: I5321db7d5ecea8f976291d2a22667b02162194e2
Reviewed-on: https://code.wireshark.org/review/27775
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/nstime.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/lua/nstime.lua b/test/lua/nstime.lua index c8ecdd2d29..00daa3e40e 100644 --- a/test/lua/nstime.lua +++ b/test/lua/nstime.lua @@ -31,7 +31,7 @@ end -- note ip only runs 3 times because it gets removed -- and bootp only runs twice because the filter makes it run -- once and then it gets replaced with a different one for the second time -local taptests = { [FRAME]=4, [OTHER]=40 } +local taptests = { [FRAME]=4, [OTHER]=44 } local function getResults() print("\n-----------------------------\n") for k,v in pairs(taptests) do @@ -143,6 +143,13 @@ test("NSTime.set-38", first == NSTime(123,100)) test("NSTime.get-39", first.secs == 123) test("NSTime.get-40", first.nsecs == 100) +local minus0_4 = NSTime() - NSTime(0,400000000) +test("NSTime.negative_tonumber-41", minus0_4:tonumber() == -0.4) +test("NSTime.negative_tostring-42", tostring(minus0_4) == "-0.400000000") +local minus0_4 = NSTime() - NSTime(1,400000000) +test("NSTime.negative_tonumber-43", minus0_4:tonumber() == -1.4) +test("NSTime.negative_tostring-44", tostring(minus0_4) == "-1.400000000") + ---------------------------------- -- revert to original test function, kinda sorta |