diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/old/vlib/encoding/base64/base64_memory_test.v | |
download | cli-tools-windows-master.tar.gz cli-tools-windows-master.tar.bz2 cli-tools-windows-master.zip |
Diffstat (limited to 'v_windows/v/old/vlib/encoding/base64/base64_memory_test.v')
-rw-r--r-- | v_windows/v/old/vlib/encoding/base64/base64_memory_test.v | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/v_windows/v/old/vlib/encoding/base64/base64_memory_test.v b/v_windows/v/old/vlib/encoding/base64/base64_memory_test.v new file mode 100644 index 0000000..a1ac47a --- /dev/null +++ b/v_windows/v/old/vlib/encoding/base64/base64_memory_test.v @@ -0,0 +1,32 @@ +import encoding.base64 + +fn test_long_encoding() { + repeats := 1000 + input_size := 3000 + + s_original := []byte{len: input_size, init: `a`} + s_encoded := base64.encode(s_original) + s_decoded := base64.decode(s_encoded) + + assert s_encoded.len > s_original.len + assert s_original == s_decoded + + mut s := 0 + + ebuffer := unsafe { malloc(s_encoded.len) } + for _ in 0 .. repeats { + resultsize := base64.encode_in_buffer(s_original, ebuffer) + s += resultsize + assert resultsize == s_encoded.len + } + + dbuffer := unsafe { malloc(s_decoded.len) } + for _ in 0 .. repeats { + resultsize := base64.decode_in_buffer(s_encoded, dbuffer) + s += resultsize + assert resultsize == s_decoded.len + } + + println('Final s: $s') + // assert s == 39147008 +} |