mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:01:42 +00:00
Add a test for Platform.localeName
Change-Id: I53b995239426b463b8a3dbd529447f016fe81d81 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215156 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Brian Quinlan <bquinlan@google.com>
This commit is contained in:
parent
b927288ed1
commit
4933f44a82
21
tests/standalone/io/platform_locale_name_test.dart
Normal file
21
tests/standalone/io/platform_locale_name_test.dart
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) 2021, 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 "dart:io";
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
// Match patterns like:
|
||||
// "en-US" (Android, iOS, MacOS, Windows)
|
||||
// "en_US", "en_US.UTF-8" (Linux)
|
||||
// "ESP-USA" (theoretically possible)
|
||||
// Assumes that the platform has a reasonably configured locale.
|
||||
var localePattern = RegExp(r"[A-Za-z]{2,4}[_-][A-Za-z]{2}");
|
||||
var localeName = Platform.localeName;
|
||||
Expect.isNotNull(
|
||||
localePattern.matchAsPrefix(localeName),
|
||||
"Platform.localeName: ${localeName} does not match "
|
||||
"${localePattern.pattern}");
|
||||
}
|
23
tests/standalone_2/io/platform_locale_name_test.dart
Normal file
23
tests/standalone_2/io/platform_locale_name_test.dart
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) 2021, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "dart:io";
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
// Match patterns like:
|
||||
// "en-US" (Android, iOS, MacOS, Windows)
|
||||
// "en_US", "en_US.UTF-8" (Linux)
|
||||
// "ESP-USA" (theoretically possible)
|
||||
// Assumes that the platform has a reasonably configured locale.
|
||||
var localePattern = RegExp(r"[A-Za-z]{2,4}[_-][A-Za-z]{2}");
|
||||
var localeName = Platform.localeName;
|
||||
Expect.isNotNull(
|
||||
localePattern.matchAsPrefix(localeName),
|
||||
"Platform.localeName: ${localeName} does not match "
|
||||
"${localePattern.pattern}");
|
||||
}
|
Loading…
Reference in a new issue