ucum 0.5.0 copy "ucum: ^0.5.0" to clipboard
ucum: ^0.5.0 copied to clipboard

Dart Library Mimicking the Unified Code for Units of Measure Library Functionality

example/example.dart

import 'package:test/test.dart';
import 'package:ucum/ucum.dart';

void main() {
  group("grey's tests", () {
    late UcumService ucumService;

    setUpAll(() {
      ucumService = getUcumService();
    });

    test('make units', () {
      final ValidatedQuantity quantity1 =
          ValidatedQuantity.fromString('4 hours');
      expect(quantity1.value.asUcumDecimal(), '4');
      expect(quantity1.unit, 'hours');
      final ValidatedQuantity quantity2 =
          ValidatedQuantity.fromString('16.5559988 mph');
      expect(ucumService.validate(quantity2.unit), isNull);
    });

    test('Equal', () {
      final ValidatedQuantity quantity3 = ValidatedQuantity.fromString('4 m');
      final ValidatedQuantity quantity4 =
          ValidatedQuantity.fromString('400 cm');
      expect(ucumService.isEqual(quantity3, quantity4), true);
      final ValidatedQuantity quantity5 =
          ValidatedQuantity.fromString('2.54 cm');
      final ValidatedQuantity quantity6 =
          ValidatedQuantity.fromString('1 inch');
      expect(ucumService.isEqual(quantity5, quantity6), true);
      expect(ucumService.isEqual(quantity6, quantity5), true);
    });
  });
}

UcumService getUcumService() => UcumService();
1
likes
140
points
667
downloads

Publisher

verified publisherfhirfli.dev

Weekly Downloads

Dart Library Mimicking the Unified Code for Units of Measure Library Functionality

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

xml

More

Packages that depend on ucum