#extends Node # Declare member variables here. Examples: # var a = 2 # var b = "text" # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass func test_bool_true(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() bitstream.put_bool(true) var res = bitstream.show() assert(res == "1") func test_bool_false(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() bitstream.put_bool(false) var res = bitstream.show() assert(res == "0") func test_uint8(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_uint8(18) res = bitstream.show() #print(res) assert(res == "00010010") bitstream.put_uint8(255) res = bitstream.show() #print(res) assert(res == "0001001011111111") # trunc number if more 255 (1205 -> 226) bitstream.put_uint8(1250) res = bitstream.show() #print(res) assert(res == "000100101111111111100010") # Ignore String (replaced by 'A' -> 0) bitstream.put_char("A") res = bitstream.show() #print(res) assert(res == "00010010111111111110001001000001") func test_sint8(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_sint8(-18) res = bitstream.show() #print(res) assert(res == "11101110") bitstream.put_sint8(-1) res = bitstream.show() #print(res) assert(res == "1110111011111111") # trunc number, reduce number bit bitstream.put_sint8(-1250) res = bitstream.show() #print(res) assert(res == "111011101111111100011110") # Ignore String (replaced by 'A' -> 0) bitstream.put_char("A") res = bitstream.show() #print(res) assert(res == "11101110111111110001111001000001") func test_uint16(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_uint16(18) res = bitstream.show() #print(res) assert(res == "0000000000010010") bitstream.put_uint16(65535) res = bitstream.show() #print(res) assert(res == "00000000000100101111111111111111") # trunc number, reduce number bit bitstream.put_uint16(14597) res = bitstream.show() #print(res) assert(res == "000000000001001011111111111111110011100100000101") func test_sint16(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_sint16(-18) res = bitstream.show() #print(res) assert(res == "1111111111101110") bitstream.put_sint16(-1) res = bitstream.show() #print(res) assert(res == "11111111111011101111111111111111") # trunc number, reduce number bit bitstream.put_sint16(-1250) res = bitstream.show() #print(res) assert(res == "111111111110111011111111111111111111101100011110") func test_uint32(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_uint32(1459747891) res = bitstream.show() #print(res) assert(res == "01010111000000011111110000110011") bitstream.put_uint32(4294967295) res = bitstream.show() #print(res) assert(res == "0101011100000001111111000011001111111111111111111111111111111111") # trunc number, reduce number bit bitstream.put_uint32(14597) res = bitstream.show() #print(res) assert(res == "010101110000000111111100001100111111111111111111111111111111111100000000000000000011100100000101") func test_sint32(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_sint32(-18) res = bitstream.show() #print(res) assert(res == "11111111111111111111111111101110") bitstream.put_sint32(-1) res = bitstream.show() #print(res) assert(res == "1111111111111111111111111110111011111111111111111111111111111111") # trunc number, reduce number bit bitstream.put_sint32(-1250) res = bitstream.show() #print(res) assert(res == "111111111111111111111111111011101111111111111111111111111111111111111111111111111111101100011110") func test_string_hexa32(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_string_hexa32("DEADBEAF") res = bitstream.show() #print(res) assert(res == "11011110101011011011111010101111") bitstream = BitStream.new() bitstream.put_string_hexa32("010011AC") res = bitstream.show() #print(res) assert(res == "00000001000000000001000110101100") func test_char(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_char("1") res = bitstream.show() #print(res) assert(res == "00110001") bitstream.put_char("A") res = bitstream.show() #print(res) assert(res == "0011000101000001") func test_string(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res bitstream.put_string("FR") res = bitstream.show() assert(res == "000000000000000000000000000000100100011001010010") func test_little_endian(): #var bitstream = preload("res://bitstream.gdns").new() var bitstream = BitStream.new() var res = bitstream.is_little_endian() print ("[bitstream] little endian : " + str(res)) func test(): print("[bitstream] Start check -> start") test_little_endian() test_bool_true() test_bool_false() test_uint8() test_sint8() test_uint16() test_sint16() test_uint32() test_sint32() test_string_hexa32() test_char() test_string() print("[bitstream] Start check -> end")