1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

math: digits function; SqrtTau; extra spaces; re writed doc's to correct form; test for factorial

This commit is contained in:
RustemB
2019-07-02 15:50:33 +05:00
committed by Alexander Medvednikov
parent 4ed67fbe7e
commit cd4fe63355
2 changed files with 69 additions and 35 deletions

View File

@@ -13,3 +13,21 @@ fn test_lcm() {
assert math.lcm(-2, -3) == 6
assert math.lcm(0, 0) == 0
}
fn test_digits() {
digits_in_10th_base := math.digits(125, 10)
assert digits_in_10th_base[0] == 5
assert digits_in_10th_base[1] == 2
assert digits_in_10th_base[2] == 1
digits_in_16th_base := math.digits(15, 16)
assert digits_in_16th_base[0] == 15
negative_digits := math.digits(-4, 2)
assert negative_digits[2] == -1
}
fn test_factorial() {
assert math.factorial(5) == 120
assert math.factorial(0) == 1
}