refactor: move reflect.Indirect test to _demo and use panic()

- Moved test from _cmptest/reflect_indirect/ to _demo/go/reflect-indirect/
- Refactored to use panic() for validation instead of fmt.Println
- Added proper assertions for all test cases

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
This commit is contained in:
xgopilot
2025-10-17 09:06:09 +00:00
parent e47728b053
commit 8d6d1b76f2
2 changed files with 31 additions and 24 deletions

View File

@@ -1,24 +0,0 @@
package main
import (
"fmt"
"reflect"
)
func main() {
x := 42
p := &x
// Test 1: Non-pointer value - should return same value
v1 := reflect.Indirect(reflect.ValueOf(x))
fmt.Printf("Non-pointer: %v\n", v1.Interface())
// Test 2: Pointer - should dereference
v2 := reflect.Indirect(reflect.ValueOf(p))
fmt.Printf("Pointer: %v\n", v2.Interface())
// Test 3: Nil pointer
var nilPtr *int
v3 := reflect.Indirect(reflect.ValueOf(nilPtr))
fmt.Printf("Nil pointer valid: %v\n", v3.IsValid())
}