Skip to content

Commit

Permalink
Move use_full_hex_values_for_flutter_colors tests (dart-lang/linter#4527
Browse files Browse the repository at this point in the history
)
  • Loading branch information
srawlins authored Jul 5, 2023
1 parent 4c92e8d commit 3812ef7
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 23 deletions.
3 changes: 3 additions & 0 deletions test/rules/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ import 'unrelated_type_equality_checks_test.dart'
import 'use_build_context_synchronously_test.dart'
as use_build_context_synchronously;
import 'use_enums_test.dart' as use_enums;
import 'use_full_hex_values_for_flutter_colors_test.dart'
as use_full_hex_values_for_flutter_colors;
import 'use_function_type_syntax_for_parameters_test.dart'
as use_function_type_syntax_for_parameters;
import 'use_is_even_rather_than_modulo_test.dart'
Expand Down Expand Up @@ -281,6 +283,7 @@ void main() {
unrelated_type_equality_checks.main();
use_build_context_synchronously.main();
use_enums.main();
use_full_hex_values_for_flutter_colors.main();
use_function_type_syntax_for_parameters.main();
use_is_even_rather_than_modulo.main();
use_key_in_widget_constructors.main();
Expand Down
109 changes: 109 additions & 0 deletions test/rules/use_full_hex_values_for_flutter_colors_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:test_reflective_loader/test_reflective_loader.dart';

import '../rule_test_support.dart';

main() {
defineReflectiveSuite(() {
defineReflectiveTests(UseFullHexValuesForFlutterColorsTest);
});
}

@reflectiveTest
class UseFullHexValuesForFlutterColorsTest extends LintRuleTest {
@override
String get lintRule => 'use_full_hex_values_for_flutter_colors';

test_dynamicArgument() async {
await assertNoDiagnostics(r'''
library dart.ui;
class Color {
Color(int v);
}
void f(dynamic a) {
Color(a);
}
''');
}

test_eightDigitHex_lower() async {
await assertNoDiagnostics(r'''
library dart.ui;
class Color {
Color(int v);
}
void f() {
Color(0x00000000);
}
''');
}

test_eightDigitHex_upper() async {
await assertNoDiagnostics(r'''
library dart.ui;
class Color {
Color(int v);
}
void f() {
Color(0X00000000);
}
''');
}

test_nonHex() async {
await assertDiagnostics(r'''
library dart.ui;
class Color {
Color(int v);
}
void f() {
Color(1);
}
''', [
lint(70, 1),
]);
}

test_sixDigitHex_lower() async {
await assertDiagnostics(r'''
library dart.ui;
class Color {
Color(int v);
}
void f() {
Color(0x000000);
}
''', [
lint(70, 8),
]);
}

test_sixDigitHex_upper() async {
await assertDiagnostics(r'''
library dart.ui;
class Color {
Color(int v);
}
void f() {
Color(0X000000);
}
''', [
lint(70, 8),
]);
}
}
23 changes: 0 additions & 23 deletions test_data/rules/use_full_hex_values_for_flutter_colors.dart

This file was deleted.

0 comments on commit 3812ef7

Please sign in to comment.