MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestSortedSetPopMax

Function TestSortedSetPopMax

IceFireDB-PubSub/test/cmd_sorted_set_test.go:1839–1903  ·  view source on GitHub ↗

Test ZPOPMAX

(t *testing.T)

Source from the content-addressed store, hash-verified

1837
1838// Test ZPOPMAX
1839func TestSortedSetPopMax(t *testing.T) {
1840 server.Clear()
1841 c, err := proto.Dial(server.Addr())
1842 ok(t, err)
1843 defer c.Close()
1844 s := server.Direct()
1845
1846 s.ZAdd("z", 1, "one")
1847 s.ZAdd("z", 2, "two")
1848 s.ZAdd("z", 2, "zwei")
1849 s.ZAdd("z", 3, "three")
1850 s.ZAdd("z", 3, "drei")
1851 s.ZAdd("z", math.Inf(+1), "inf")
1852
1853 mustDo(t, c,
1854 "ZPOPMAX", "z", "2",
1855 proto.Strings("inf", "inf", "three", "3"),
1856 )
1857
1858 // Get one - without count
1859 mustDo(t, c,
1860 "ZPOPMAX", "z",
1861 proto.Strings("drei", "3"),
1862 )
1863
1864 // weird cases.
1865 mustDo(t, c,
1866 "ZPOPMAX", "z", "-100",
1867 proto.Strings(),
1868 )
1869
1870 // Nonexistent key
1871 mustDo(t, c,
1872 "ZPOPMAX", "nosuch", "1",
1873 proto.Strings(),
1874 )
1875
1876 // Get more than exist
1877 mustDo(t, c,
1878 "ZPOPMAX", "z", "100",
1879 proto.Strings("zwei", "2", "two", "2", "one", "1"),
1880 )
1881
1882 t.Run("errors", func(t *testing.T) {
1883 mustDo(t, c,
1884 "ZPOPMAX",
1885 proto.Error(errWrongNumber("zpopmax")),
1886 )
1887
1888 mustDo(t, c,
1889 "ZPOPMAX", "set", "noint",
1890 proto.Error(msgInvalidInt),
1891 )
1892 mustDo(t, c,
1893 "ZPOPMAX", "set", "1", "toomany",
1894 proto.Error(msgSyntaxError),
1895 )
1896

Callers

nothing calls this directly

Calls 12

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
StringsFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
errWrongNumberFunction · 0.70
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected