test-check

lucasbradstreet 2016-01-29T06:51:39.000004Z

Howdy

2016-01-29T08:12:01.000005Z

Hi @lucasbradstreet.

2016-01-29T08:31:10.000006Z

So I was hoping to get some advice about the properties I could test for the convert function found at https://github.com/paulspencerwilliams/gormanic/blob/master/src/gormanic/core.clj

lucasbradstreet 2016-01-29T08:38:33.000008Z

testing the string generated by convert will be a bit annoying

lucasbradstreet 2016-01-29T08:38:38.000009Z

but you could test the functions that it uses

lucasbradstreet 2016-01-29T08:38:57.000010Z

some easy ones, do any of them return a negative month, day, year

lucasbradstreet 2016-01-29T08:39:17.000011Z

or a month larger than 12 (or 11 if 0 indexed), day greater than 31, tec

lucasbradstreet 2016-01-29T08:39:18.000012Z

etc

2016-01-29T08:41:21.000013Z

okay.

2016-01-29T08:42:39.000014Z

I understand testing the boundaries aren’t crossed like you mentioned. If I returning a map rather than string, with day, month and year keys, it would be easier to ‘parse’ and thus test. Would quickcheck style testing help then?

2016-01-29T08:44:27.000015Z

Would I use it to test the function actually returns the correct resultant date? I was thinking that I would have to model the gormanic calendar in the test, and for a random set of input dates, ensure convert would return the appropriate gormanic date. But this would be in effect duplicating SUT code in the test?

2016-01-29T08:45:39.000016Z

Apologies, if I’ve asked a common question, I’ve watched a few videos etc but many properties seem abstract, or away from the concrete problem if that makes sense?

lucasbradstreet 2016-01-29T08:48:17.000017Z

Yeah, a map definitely seems easier

lucasbradstreet 2016-01-29T08:49:21.000018Z

I don’t know enough about the gormanic calender to provide some good properties there 😕

lucasbradstreet 2016-01-29T08:50:56.000019Z

The wikipedia page isn’t all that much help, heh

lucasbradstreet 2016-01-29T08:55:18.000020Z

One idea is if you could provide a comparator function for both date types, and make sure that if one random date is greater than another random date in the gregorian calender, then it’s also greater in the calculated gormanic calender date.

2016-01-29T08:58:13.000021Z

hehe, oh sorry, the gormanic calendar is made up for a kata. okay, I need to think about your idea for the comparator function. If I developed one, would you not simply say that for all inputs, the output compares exactly to the input?

lucasbradstreet 2016-01-29T08:58:37.000022Z

Exactly

2016-01-29T09:00:07.000023Z

okay. Cheers, let me think about that and I’ll have a play.