Sha256: 4176d7341bacf939dc86c343cb67855fd80d8539712c8a96b6538151154d120a

Contents?: true

Size: 1.71 KB

Versions: 96

Compression:

Stored size: 1.71 KB

Contents

import "package:test/test.dart";
import "package:gigasecond/gigasecond.dart";

DateTime birthDate;
DateTime expectedDate;
Gigasecond gigasecond;

void main() {
  group("Gigasecond", gigasecondTests);
}

void gigasecondTests() {
  // The setUp() function is used to share code between tests. It is executed
  // before every test in a group or test suite.
  setUp(() {
    birthDate = new DateTime.utc(2015, DateTime.SEPTEMBER, 14);
  });

  group("since midnight tests", sinceMidnightTests);
  group("at night tests", atNightTests);
  group("unixEpoch tests", unixEpochTests);
}

void sinceMidnightTests() {
  setUp(() {
    gigasecond = new Gigasecond(birthDate);
    expectedDate = new DateTime.utc(2047, DateTime.MAY, 23, 1, 46, 40);
  });

  test("tells a gigasecond anniversary since midnight", () {
    expect(gigasecond.date(), equals(expectedDate));
  });

  test("make sure calling \"date()\" doesn't mutate value", () {
    gigasecond.date();
    expect(gigasecond.date(), equals(expectedDate));
  });
}

void atNightTests() {
  setUp(() {
    birthDate = birthDate.add(new Duration(hours: 23, minutes: 59, seconds: 59));
    gigasecond = new Gigasecond(birthDate);
    expectedDate = new DateTime.utc(2047, DateTime.MAY, 24, 1, 46, 39);
  });

  test("tells the anniversary is next day when you are born at night", () {
    expect(gigasecond.date(), equals(expectedDate));
  });
}

void unixEpochTests() {
  setUp(() {
    birthDate = new DateTime.utc(1959, DateTime.JULY, 19, 5, 13, 45);
    gigasecond = new Gigasecond(birthDate);
    expectedDate = new DateTime.utc(1991, DateTime.MARCH, 27, 7, 0, 25);
  });

  test("even works before 1970 (beginning of Unix epoch)", () {
    expect(gigasecond.date(), equals(expectedDate));
  });
}

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
trackler-2.2.1.142 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.141 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.140 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.139 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.138 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.137 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.136 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.135 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.134 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.133 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.132 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.131 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.130 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.129 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.128 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.127 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.126 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.125 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.124 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart
trackler-2.2.1.123 tracks/dart/exercises/gigasecond/test/gigasecond_test.dart