Исходники и презентации

This commit is contained in:
2025-05-23 07:26:39 +03:00
parent aa948179d5
commit 02d8430a3a
514 changed files with 13773 additions and 0 deletions

View File

@ -0,0 +1,56 @@
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
// go test -v homework_test.go
type Person struct {
Name string `properties:"name"`
Address string `properties:"address,omitempty"`
Age int `properties:"age"`
Married bool `properties:"married"`
}
func Serialize(person Person) string {
// need to implement
return ""
}
func TestSerialization(t *testing.T) {
tests := map[string]struct {
person Person
result string
}{
"test case with empty fields": {
result: "name=\nage=0\nmarried=false",
},
"test case with fields": {
person: Person{
Name: "John Doe",
Age: 30,
Married: true,
},
result: "name=John Doe\nage=30\nmarried=true",
},
"test case with omitempty field": {
person: Person{
Name: "John Doe",
Age: 30,
Married: true,
Address: "Paris",
},
result: "name=John Doe\naddress=Paris\nage=30\nmarried=true",
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
result := Serialize(test.person)
assert.Equal(t, test.result, result)
})
}
}