Skip to content

Commit ceeb375

Browse files
committed
test: Remove static numbers in tox constants tests.
1 parent b12cc54 commit ceeb375

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Diff for: BUILD.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ project(license = "gpl3-https")
99
# srcs = ["//c-toxcore:" + src],
1010
# outs = ["src/FFI/%s.hs" % "/".join([mod.capitalize() for mod in src[:-2].split("/")])],
1111
# cmd = "$(location //hs-apigen/tools:apigen) -hs $< > $@",
12-
# exec_tools = ["//hs-apigen/tools:apigen"],
12+
# tools = ["//hs-apigen/tools:apigen"],
1313
# tags = ["no-cross"],
1414
# ) for src in [
1515
# "tox/tox.h",
@@ -25,7 +25,7 @@ haskell_library(
2525
],
2626
src_strip_prefix = "src",
2727
tags = ["no-cross"],
28-
version = "0.2.12",
28+
version = "0.2.19",
2929
visibility = ["//visibility:public"],
3030
deps = [
3131
"//c-toxcore",

Diff for: test/Network/Tox/C/ToxSpec.hs

+12-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE Trustworthy #-}
44
module Network.Tox.C.ToxSpec where
55

6+
import Control.Monad (when)
67
import qualified Data.ByteString as BS
78
import Test.Hspec
89
import Test.QuickCheck
@@ -46,6 +47,12 @@ must :: Show a => IO (Either a b) -> IO b
4647
must = (getRight =<<)
4748

4849

50+
shouldBeBetween :: (Show a, Ord a) => a -> (a, a) -> IO ()
51+
shouldBeBetween v (lo, hi) = do
52+
when (v < lo || v > hi) $
53+
expectationFailure $ "value " <> show v <> " should be between " <> show lo <> " and " <> show hi
54+
55+
4956
spec :: Spec
5057
spec = do
5158
describe "tox_version_is_compatible" $ do
@@ -61,12 +68,12 @@ spec = do
6168
fromIntegral C.tox_public_key_size `shouldBe` boxPK
6269
fromIntegral C.tox_secret_key_size `shouldBe` boxSK
6370
C.tox_address_size `shouldBe` C.tox_public_key_size + 6
64-
C.tox_max_name_length `shouldBe` 128
65-
C.tox_max_status_message_length `shouldBe` 1007
66-
C.tox_max_friend_request_length `shouldBe` 1016
71+
C.tox_max_name_length `shouldBeBetween` (100, 200)
72+
C.tox_max_status_message_length `shouldBeBetween` (500, 1400)
73+
C.tox_max_friend_request_length `shouldBeBetween` (500, 1400)
6774
C.tox_max_message_length `shouldBe` C.tox_max_custom_packet_size - 1
68-
C.tox_max_custom_packet_size `shouldBe` 1373
69-
C.tox_max_filename_length `shouldBe` 255
75+
C.tox_max_custom_packet_size `shouldBeBetween` (500, 1400)
76+
C.tox_max_filename_length `shouldBeBetween` (100, 255)
7077
C.tox_hash_length `shouldBe` C.tox_file_id_length
7178

7279
describe "Options" $ do

0 commit comments

Comments
 (0)