mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(utils.spec.qml): add tests on times
This commit is contained in:
parent
5d65384b97
commit
0f48d2047d
1 changed files with 27 additions and 0 deletions
|
|
@ -95,6 +95,33 @@ TestCase {
|
|||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
function test_times1_data () {
|
||||
return [
|
||||
{
|
||||
cb: function (n) { return n * 2 },
|
||||
n: 10,
|
||||
output: [ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 ]
|
||||
},
|
||||
{
|
||||
cb: function (n) { return n % 2 ? 1 : 0 },
|
||||
n: 10,
|
||||
output: [ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
function test_times1 (data) {
|
||||
compare(Utils.times(data.n, data.cb), data.output)
|
||||
}
|
||||
|
||||
function test_times2 () {
|
||||
var sum = 0
|
||||
Utils.times(5, function (i) { sum += (i + 1) })
|
||||
compare(sum, 15)
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
function test_isString_data () {
|
||||
return [
|
||||
{ input: 'foo', output: true },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue