(t *testing.T)
| 936 | } |
| 937 | |
| 938 | func TestAttributeExprHasDefaultValue(t *testing.T) { |
| 939 | var ( |
| 940 | object = &Object{ |
| 941 | &NamedAttributeExpr{ |
| 942 | Name: "foo", |
| 943 | Attribute: &AttributeExpr{ |
| 944 | DefaultValue: 1, |
| 945 | }, |
| 946 | }, |
| 947 | &NamedAttributeExpr{ |
| 948 | Name: "bar", |
| 949 | Attribute: &AttributeExpr{}, |
| 950 | }, |
| 951 | } |
| 952 | ) |
| 953 | cases := map[string]struct { |
| 954 | attName string |
| 955 | typ DataType |
| 956 | expected bool |
| 957 | }{ |
| 958 | "has default value": { |
| 959 | attName: "foo", |
| 960 | typ: object, |
| 961 | expected: true, |
| 962 | }, |
| 963 | "no default value": { |
| 964 | attName: "bar", |
| 965 | typ: object, |
| 966 | expected: false, |
| 967 | }, |
| 968 | "not object": { |
| 969 | typ: Boolean, |
| 970 | expected: false, |
| 971 | }, |
| 972 | } |
| 973 | |
| 974 | for k, tc := range cases { |
| 975 | attribute := AttributeExpr{ |
| 976 | Type: tc.typ, |
| 977 | } |
| 978 | if actual := attribute.HasDefaultValue(tc.attName); tc.expected != actual { |
| 979 | t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected) |
| 980 | } |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | func TestValidationExprHasRequiredOnly(t *testing.T) { |
| 985 | var ( |
nothing calls this directly
no test coverage detected