[#310] *: Implement string converters for enumerations

Implement `String` / `FromString` method pair in all levels of enum
definitions. From now `String()` returns canonical protojson-compatible
values.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-18 15:27:01 +03:00 committed by Alex Vanin
parent fdea892db7
commit 616b4b71a1
25 changed files with 1053 additions and 76 deletions

View file

@ -29,3 +29,15 @@ func TestClauseFromV2(t *testing.T) {
require.Equal(t, item.cV2, item.c.ToV2())
}
}
func TestClause_String(t *testing.T) {
toPtr := func(v Clause) *Clause {
return &v
}
testEnumStrings(t, new(Clause), []enumStringItem{
{val: toPtr(ClauseDistinct), str: "DISTINCT"},
{val: toPtr(ClauseSame), str: "SAME"},
{val: toPtr(ClauseUnspecified), str: "CLAUSE_UNSPECIFIED"},
})
}