Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: recipes/test/core/strings/concatenating_strings_test.dart

Issue 12335109: Strings recipes for the Dart Cookbook (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Fixed typos. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: recipes/test/core/strings/concatenating_strings_test.dart
diff --git a/recipes/test/core/strings/concatenating_strings_test.dart b/recipes/test/core/strings/concatenating_strings_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..82da5cf471205d78d34a6ef6e3a39e06c7e4413d
--- /dev/null
+++ b/recipes/test/core/strings/concatenating_strings_test.dart
@@ -0,0 +1,51 @@
+library concatenating_strings_test;
+
+import 'package:unittest/unittest.dart';
+
+void main() {
+ group('concatenating strings', () {
+ group('using adjacent string literals', () {
+ var string = 'Dart is fun!';
+
+ test('on one line', () {
+ expect('Dart' ' is' ' fun!', equals(string));
+ });
+
+ test('over many lines', () {
+ expect('Dart'
+ ' is'
+ ' fun!', equals(string));
+ });
+
+ test('over one or many lines', () {
+ expect('Dart' ' is'
+ ' fun!', equals(string));
+ });
+
+ test('using multiline strings', () {
+ expect('''Peanut
+butter '''
+'''and
+jelly''', equals('Peanut\nbutter and\njelly'));
+ });
+
+ test('combining single and multiline string', () {
+ expect('Peanut ' 'butter'
+ ''' and
+jelly''', equals('Peanut butter and\njelly'));
+ });
+ });
+
+ group('using alternatives to string literals', () {
+ var string = "Dewey Cheatem and Howe";
+
+ test(': concat()', () {
+ expect('Dewey'.concat(' Cheatem').concat(' and').concat( ' Howe'), equals(string));
+ });
+
+ test(': join()', () {
+ expect(['Dewey', 'Cheatem', 'and', 'Howe'].join(' '), equals(string));
+ });
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698