0
点赞
收藏
分享

微信扫一扫

python单元测试框架(继承、unittest参数化、断言、测试报告)

古月无语 2023-10-21 阅读 50

【Edabit 算法 ★☆☆☆☆☆】 Convert Age to Days

algebra algorithms math

Instructions
Examples
calcAge(65) // 23725
calcAge(0) // 0
calcAge(20) // 7300
Notes
  • Use 365 days as the length of a year for this challenge.
  • Ignore leap years and days between last birthday and now.
  • Expect only positive integer inputs.
Solutions
function calcAge(age) {
    return 365*age;
}

TestCases
let Test = (function(){
    return {
        assertEquals:function(actual,expected){
            if(actual !== expected){
                let errorMsg = `actual is ${actual},${expected} is expected`;
                throw new Error(errorMsg);
            }
        }
    }
})();

Test.assertEquals(calcAge(10), 3650)
Test.assertSimilar(calcAge(0), 0)
Test.assertSimilar(calcAge(73), 26645)

举报

相关推荐

0 条评论