diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2021-07-21 23:00:00 -0500 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2021-07-21 23:00:00 -0500 |
| commit | 47fbc0ec08ae75c62df1b7ce6c99c56ad9827a9a (patch) | |
| tree | 9b69897151ceb0fb49147404e1289d0532d10ccc /snap/parsing_test.go | |
| parent | 43d2d2f3d912370b7aea05a767151d3b4def778e (diff) | |
Added parser for +- syntax for relative references to snapshots
Diffstat (limited to 'snap/parsing_test.go')
| -rw-r--r-- | snap/parsing_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/snap/parsing_test.go b/snap/parsing_test.go new file mode 100644 index 0000000..1a87723 --- /dev/null +++ b/snap/parsing_test.go @@ -0,0 +1,31 @@ +package snap + +import "testing" + +func TestRelativeParsing(t * testing.T) { + cases := []struct { + snapish string + snapshot string + offset int + } { + {"snapshot", "snapshot", 0}, + {"testing--", "testing", -2}, + {"%SNAPSHOT%^+++", "%SNAPSHOT%^", 3}, + {"--prefixed", "--prefixed", 0}, + {"+++", "", 3}, + {"---", "", -3}, + {"+5", "", 5}, + {"-3", "", -3}, + {"+", "", 1}, + {"-", "", -1}, + {`"-"`, "-", 0}, + } + + for _, c := range cases { + got := ToRelative(c.snapish) + + if got.offset != c.offset || got.snapshot != c.snapshot { + t.Errorf("ToRelative(%s) == %+v, wanted %+v", c.snapish, got, c) + } + } +}
\ No newline at end of file |
