aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/builtin/linux_bare/old/.checks/structs/structs.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/builtin/linux_bare/old/.checks/structs/structs.v
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/builtin/linux_bare/old/.checks/structs/structs.v')
-rw-r--r--v_windows/v/vlib/builtin/linux_bare/old/.checks/structs/structs.v42
1 files changed, 42 insertions, 0 deletions
diff --git a/v_windows/v/vlib/builtin/linux_bare/old/.checks/structs/structs.v b/v_windows/v/vlib/builtin/linux_bare/old/.checks/structs/structs.v
new file mode 100644
index 0000000..f63285d
--- /dev/null
+++ b/v_windows/v/vlib/builtin/linux_bare/old/.checks/structs/structs.v
@@ -0,0 +1,42 @@
+module main
+import forkedtest
+
+struct SimpleEmptyStruct{
+}
+
+struct NonEmptyStruct{
+ x int
+ y int
+ z int
+}
+
+fn check_simple_empty_struct(){
+ s := SimpleEmptyStruct{}
+ addr_s := &s
+ str_addr_s := ptr_str( addr_s )
+ assert !isnil(addr_s)
+ assert str_addr_s.len > 3
+ println(str_addr_s)
+}
+
+fn check_non_empty_struct(){
+ a := NonEmptyStruct{1,2,3}
+ b := NonEmptyStruct{4,5,6}
+ assert sizeof(NonEmptyStruct) > 0
+ assert sizeof(SimpleEmptyStruct) < sizeof(NonEmptyStruct)
+ assert a.x == 1
+ assert a.y == 2
+ assert a.z == 3
+ assert b.x + b.y + b.z == 15
+ assert ptr_str(&a) != ptr_str(&b)
+ println('sizeof SimpleEmptyStruct:' + i64_str( sizeof(SimpleEmptyStruct) , 10 ))
+ println('sizeof NonEmptyStruct:' + i64_str( sizeof(NonEmptyStruct) , 10 ))
+}
+
+fn main(){
+ mut fails := 0
+ fails += forkedtest.normal_run(check_simple_empty_struct, "check_simple_empty_struct")
+ fails += forkedtest.normal_run(check_non_empty_struct, "check_non_empty_struct")
+ assert fails == 0
+ sys_exit(0)
+}