1plugin = 2{ 3 type = "piglet", 4 name = "piglet::decode_data", 5 test = function() 6 dofile(SCRIPT_DIR .. "/../common.lua") 7 return run_tests(tests) 8 end 9} 10 11DEFAULT_VALUES = 12{ 13 sp = 0, 14 dp = 0, 15 decode_flags = 0, 16 type = 0 17} 18 19VALUES = 20{ 21 sp = 1, 22 dp = 2, 23 decode_flags = 3, 24 type = 4 25} 26 27IP4 = [[ 2845 | 00 | 00 46 | 00 00 | 00 00 | 01 | 06 2900 00 | 00 00 00 01 | 00 00 00 02 30 3100 00 | 00 00 | 00 00 00 00 | 00 00 00 00 | 06 02 3200 00 ff ff | 00 00 | 00 00 | 00 00 33]] 34 35tests = 36{ 37 initialize_default = function() 38 local dd = DecodeData.new() 39 assert(dd) 40 check.tables_equal(DEFAULT_VALUES, dd:get()) 41 end, 42 43 initialize_with_table = function() 44 local dd = DecodeData.new(VALUES) 45 check.tables_equal(VALUES, dd:get()) 46 end, 47 48 ip_api = function() 49 local dd = DecodeData.new(VALUES) 50 local ip = dd:get_ip_api() 51 local raw = IP4:encode_hex() 52 ip:set_ip4(raw) 53 end 54} 55