Skip to content

Commit

Permalink
Improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lamnhan066 committed Aug 23, 2024
1 parent bc95372 commit 8116eec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/src/utils/print_debug.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import 'package:flutter/foundation.dart';
import 'package:language_helper/src/language_helper.dart';

/// Improve code coverage for debug logs
bool isTestingDebugLog = false;

/// Internal function, print debug log
void printDebug(Object? Function() object) => LanguageHelper.instance.isDebug
? debugPrint('[Language Helper] ${object()}')
: null;
void printDebug(Object? Function() object) {
assert(() {
if (isTestingDebugLog) {
object();
}
return true;
}());

if (LanguageHelper.instance.isDebug) {
debugPrint('[Language Helper] ${object()}');
}
}
2 changes: 2 additions & 0 deletions test/language_helper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:language_code/language_code.dart';
import 'package:language_helper/language_helper.dart';
import 'package:language_helper/src/mixins/update_language.dart';
import 'package:language_helper/src/utils/print_debug.dart';
import 'package:language_helper/src/utils/utils.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand All @@ -26,6 +27,7 @@ void main() async {
StreamSubscription? languageSub;

setUpAll(() async {
isTestingDebugLog = true;
await languageHelper.initial(
data: dataList,
initialCode: LanguageCodes.en,
Expand Down

0 comments on commit 8116eec

Please sign in to comment.