aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--refined/refined_test.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/refined/refined_test.go b/refined/refined_test.go
index 118eef6..deda5ee 100644
--- a/refined/refined_test.go
+++ b/refined/refined_test.go
@@ -38,9 +38,6 @@ func (AccountName) Build(v refined.Prevalue[AccountName, string]) AccountName {
return AccountName{refined.Build(v)}
}
-// Example for how to use Literal() to declare a pseudo-const value.
-var reservedAccountName = refined.Literal[AccountName]("reserved")
-
// Example for how to access the contained value in computations.
func (n AccountName) ContainerName() string {
return fmt.Sprintf("container-for-%s", n.Raw())
@@ -59,3 +56,17 @@ func TestAccountName(t *testing.T) {
err = json.Unmarshal(buf2, &d2)
AssertEqual(t, err.Error(), "foo")
}
+
+func TestRefinedMapKeys(t *testing.T) {
+ var (
+ foo = refined.Literal[AccountName]("foo")
+ bar = refined.Literal[AccountName]("bar")
+ )
+ m := map[AccountName]int{
+ foo: 3,
+ bar: 1,
+ }
+ // TODO: AccountName is not an ordered type; we might need stuff like slices.Sorted() in package refined
+ // AssertEqual(slices.Sorted(maps.Keys(m)), []AccountName{bar, foo})
+ _ = m
+}