Testing Rebecca Black’s Claims
Posted by Kurt on March 25th, 2011I was unsure about some of the bold claims that Rebecca Black made in her latest hit video, so I wrote some unit tests for it. It turns out she is telling the truth!
public void testRebeccaIsntLying() {
Calendar rebeccasCalendar =
Calendar.getInstance(TimeZone.getTimeZone("America/Los_Angeles"));
// The song went viral on Friday, March 11, 2011
rebeccasCalendar.set(2011, Calendar.MARCH, 11);
// Yesterday was Thursday, Thursday
rebeccasCalendar.add(Calendar.DAY_OF_MONTH, -1);
assertEquals(Calendar.THURSDAY, rebeccasCalendar.get(Calendar.DAY_OF_WEEK));
// Today i-is Friday, Friday (Partyin’)
rebeccasCalendar.set(2011, 2, 11);
assertEquals(Calendar.FRIDAY, rebeccasCalendar.get(Calendar.DAY_OF_WEEK));
// Tomorrow is Saturday
rebeccasCalendar.add(Calendar.DAY_OF_MONTH, 1);
assertEquals(Calendar.SATURDAY, rebeccasCalendar.get(Calendar.DAY_OF_WEEK));
// And Sunday comes afterwards
rebeccasCalendar.add(Calendar.DAY_OF_MONTH, 1);
assertEquals(Calendar.SUNDAY, rebeccasCalendar.get(Calendar.DAY_OF_WEEK));
}
I sent this code out for review at work, and received quite a bit of insightful feedback from my co-workers:
- As you mentioned two lines up, “yesterday was Thursday, Thursday”. Do we need to assertEquals twice?
- I appreciate the attempt, but I have to say I find your test lacking. For starters, you only assert that yesterday was Thursday once. I’d see two sequential assertions as the absolute minimum. More concerningly, a crucial property of the calendar is that it can be used to determine whether or not we need to get down. Yet I see no assertion that we need to get down if and only if it is indeed Friday. Even if, in fact, it proves that no one is looking forward to the weekend, I don’t believe your test will catch it, to say nothing of our current observed state of partying. But these are just examples. Who needs a Calendar object if this is all it’s good for?
- Shouldn’t the time zone be determined dynamically? Rebecca may be traveling.
- I’d ask you to assert that she has chosen the appropriate seat, but this may be out of the scope of this change. A TODO will be fine.
- While you are adding the above test, I would like you to consider updating this test case as well to assert that Rebecca is indeed looking forward to the weekend, as well as partying partying during the weekend, as appropriate given the day.
- Can you devise tests for the following constraints made in the original documentation: 1. Gotta get down on Friday. (e.g. ASSERT(didGetDown) 2. Everybody’s looking forward to the weekend.
On June 28-30th, RIT hosted a 3 day workshop for area math and computer science high school teachers called
For fun, I calculated my
You knew you were headed for a career in Computer Science when…
My job is going great. I really love the work environment and people at Google. Everyone is willing to take time out of their day to help you with whatever you need…which is good because the project I’m working on has a very high learning curve. It uses a ton of Google-centric infastructure pieces that all work together in a very specific way. Since I’ve had no exposure to these technologies before, work has been going a little slow (lots of reading of other’s code and documentation, not a lot of coding). It’s a bit frustrating because it’s hard to measure productivity when most of your time is spent inputting knowledge (into your own brain), not outputting knowledge (to others). However, this means I’m learning something new every day (which is exciting). I’ll also excited to report that I’ll be continuing my work on Video CAPTCHAs at Google :)
One of the main reasons that I decided on the apartment that I’m in is that it came with a free garaged parking spot my for S4. However, I’ve quickly realized that having a car down here is rather pointless. I’ve only used it two times since moving down here: 1) buying furniture on move in day 2) returning an air mattress to BJs. Other than that, it sits in the garage and looks at me in anger: it wants to be driven. Next weekend I’ll be driving up to Rochester to present at the IEEE WNYIP 2008 workshop…that’ll cheer my car up :) Also, gas is really cheap (comparatively) down here: $3.30/gallon for regular.
I do all my weekday eating at Google: breakfast (sometimes), lunch (always), and dinner (except on Fridays). Because of this, I have very little (read: no) food in my fridge. In fact, all I have at my apartment is 3 mini-bags of popcorn and some soda. On the weekends, I go out to eat. There’s no sense in going grocery shopping for the weekend only. I’m sure at some point I’ll stock my cabinets with non-perishables like soup, etc. Also I should note that I may end up dying of mercury poisoning due to the amount of fish I’m eating at Google every day.
In the spirit of the many xkcd comics, here is one of my (new) hobbies: tossing whiteboard markers. In the massive amounts of time I spend alone in my lab, I’ve developed a new game similar to an egg toss to entertain me while my code is executing. I’ll caution you in advance that it’s both extremely addicting and surprisingly loud. Oh yea, you will get some funny looks from anyone who witnesses the game.
Well I finally switched to a real blogging platform, namely WordPress. Since it will be a lot easier to post content, that means I should be posting more often (in theory at least). Also, I stole my theme choice from my friend’s blog @
I graduated from the
Recent Comments