Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing unit tests and Updating Dart SDK to support null safety #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 0 additions & 160 deletions example/pubspec.lock

This file was deleted.

3 changes: 1 addition & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ description: A new Flutter project.
version: 1.0.0+1

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.17.1 <3.0.0"

dependencies:
flutter:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
persian_number_utility:

dev_dependencies:
Expand Down
5 changes: 0 additions & 5 deletions pubspec.lock

This file was deleted.

2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ homepage: https://github.com/mehdi-nemati/persian_number_utility

environment:
sdk: '>=2.12.0 <3.0.0'
dev_dependencies:
test: ^1.25.2
61 changes: 56 additions & 5 deletions test/persian_number_utility_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
// import 'package:flutter_test/flutter_test.dart';
import 'package:test/test.dart';
import 'package:persian_number_utility/persian_number_utility.dart';

// void main() {
// test('adds one to input values', () {
// });
// }
void main() {
group('Number to word methods', () {
group('converting English numbers to words', () {
test('1000 to english word', () {
expect(NumberUtility.toWord('1000', NumStrLanguage.English),
'one thousand');
});
test('100 to english word', () {
expect(
NumberUtility.toWord('100', NumStrLanguage.English), 'one hundred');
});
});

group('converting Farsi numbers to words', () {
test('1000 to persian word', () {
expect(NumberUtility.toWord('1000', NumStrLanguage.Farsi), 'هزار');
});
test('100 to persian word', () {
expect(NumberUtility.toWord('100', NumStrLanguage.Farsi), 'صد');
});
test('10522 to persian word', () {
expect(NumberUtility.toWord('10522', NumStrLanguage.Farsi),
'ده هزار و پانصد و بیست و دو');
});
});
});

group('Persian word to number methods', () {
test('converting 21000', () {
expect(NumberUtility.toNumber('بیست و یک هزار'), 21000);
});
test('converting 21000', () {
expect(NumberUtility.toNumber('صد و بیست و دو'), 122);
});
});

group('seRagham method test', () {
test('seRagham', () {
expect(NumberUtility.seRagham('122500000'), '122,500,000');
});
test('seRagham with custom separator', () {
expect(NumberUtility.seRagham('99999999',separator: '|'), '99|999|999');
});
});

group('changeDigit method test', () {
test('English to Persian digits', () {
expect(NumberUtility.changeDigit('1234567890',NumStrLanguage.Farsi), '۱۲۳۴۵۶۷۸۹۰');
});
test('Persian to English digits', () {
expect(NumberUtility.changeDigit('۱۲۳۴۵۶۷۸۹۰',NumStrLanguage.English), '1234567890');
});
});
}