1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- # unit_of
- assert_eq(unit_of(0), 1)
- assert_eq(unit_of(1), 1)
- assert_eq(unit_of(1.2345), 1)
- assert_eq(unit_of(1 m), m)
- assert_eq(unit_of(1.2345 m), m)
- assert_eq(unit_of(1 m^2/s), m^2/s)
- assert_eq(unit_of(1.2345 m^2/s), m^2/s)
- # value_of
- assert_eq(value_of(0), 0)
- assert_eq(value_of(1), 1)
- assert_eq(value_of(1.2345), 1.2345)
- assert_eq(value_of(1 m), 1)
- assert_eq(value_of(1.2345 m), 1.2345)
- assert_eq(value_of(1 m^2/s), 1)
- assert_eq(value_of(1.2345 m^2/s), 1.2345)
- # hypot
- assert_eq(hypot2(3, 4), 5)
- assert_eq(hypot2(3 m, 4 m), 5 m)
- assert_eq(hypot3(8, 9, 12), 17)
- assert_eq(hypot3(8 m, 9 m, 12 m), 17 m)
- # trigonometry_extra
- assert_eq(cot(0.3), 3.2327281, 1e-5)
- assert_eq(acot(0.3), 1.2793395, 1e-5)
- assert_eq(coth(0.3), 3.4327384, 1e-5)
- assert_eq(acoth(1.3), 1.018441, 1e-5)
- assert_eq(secant(0.3), 1.0467516, 1e-5)
- assert_eq(arcsecant(1.3), 0.693160, 1e-5)
- assert_eq(csc(0.3), 3.3838634, 1e-5)
- assert_eq(acsc(1.3), 0.877636, 1e-5)
- assert_eq(sech(1.3), 0.507379, 1e-5)
- assert_eq(asech(0.3), 1.873820, 1e-5)
- assert_eq(csch(0.3), 3.283853, 1e-5)
- assert_eq(acsch(0.3), 1.918896, 1e-5)
- # strings
- assert_eq(str_length(""), 0)
- assert_eq(str_length("foo"), 3)
- assert(str_slice("hello world", 0, 5) == "hello")
- assert(str_slice("hello world", 6, 11) == "world")
- assert(str_slice("hello world", 0, 0) == "")
- assert(str_slice("hello world", 0, 100) == "")
- assert(str_append("foo", "bar") == "foobar")
- assert(str_contains("hello world", "hello"))
- assert(str_contains("hello world", "world"))
- assert(str_contains("hello world", "HELLO") == false)
- assert(str_replace("hello world", "hello", "HEY") == "HEY world")
- assert(str_replace("xxx", "x", "yY") == "yYyYyY")
- assert(str_replace("a b", " ", " ") == "a b")
- assert(str_repeat("xy", 3) == "xyxyxy")
- assert((0b0 -> bin) == "0b0")
- assert((0b1 -> bin) == "0b1")
- assert((0b10 -> bin) == "0b10")
- assert((0b11 -> bin) == "0b11")
- assert((0b10101010101010101010101010101010 -> bin) == "0b10101010101010101010101010101010")
- assert((-0b11110000 -> bin) == "-0b11110000")
- assert((0o0 -> oct) == "0o0")
- assert((0o1 -> oct) == "0o1")
- assert((0o7 -> oct) == "0o7")
- assert((0o10 -> oct) == "0o10")
- assert((0o77 -> oct) == "0o77")
- assert((0o12345670 -> oct) == "0o12345670")
- assert((-0o12345670 -> oct) == "-0o12345670")
- assert((0x0 -> hex) == "0x0")
- assert((0x1 -> hex) == "0x1")
- assert((0x9 -> hex) == "0x9")
- assert((0xa -> hex) == "0xa")
- assert((0xf -> hex) == "0xf")
- assert((0xabc1234567890 -> hex) == "0xabc1234567890")
- assert((-0xc0ffee -> hex) == "-0xc0ffee")
|