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

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: Made most changes requested my Kathy. Created 7 years, 9 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..8e9e0d9741eae4568b93d173d7e5446a7987387c
--- /dev/null
+++ b/recipes/test/core/strings/concatenating_strings_test.dart
@@ -0,0 +1,51 @@
+library concatenating_strings_test;
+
+import 'package:unittest/unittest.dart';
+
+String filmToWatch() => 'The Big Lebowski';
+
+void main() {
+ group('concatenating strings', () {
+ group('using adjacent string literals', () {
+ test('on one line', () {
+ expect('Dart' ' is' ' fun!', equals('Dart is fun!'));
+ });
+
+ test('over many lines', () {
+ expect('Dart'
+ ' is'
+ ' fun!', equals('Dart is fun!'));
+ });
+
+ test('over one or many lines', () {
+ expect('Dart' ' is'
+ ' fun!', equals('Dart is fun!'));
+ });
+
+ test('using multiline strings', () {
+ expect('''Peanut
+butter '''
+'''and
+jelly''', equals('Peanut\nbutter and\njelly'));
+ });
+
+ test('combining single and multiline string', () {
+ expect('Dewey ' 'Cheatem'
+ ''' and
+Howe''', equals('Dewey Cheatem and\nHowe'));
+ });
+ });
+
+ group('using alternatives to string literals', () {
+ test(': concat()', () {
+ var film = filmToWatch();
+ film = film.concat('\n');
+ expect(film, equals('The Big Lebowski\n'));
+ });
+
+ test(': join()', () {
+ expect(['The', 'Big', 'Lebowski'].join(' '), equals('The Big Lebowski'));
+ });
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698