LCOV - code coverage report
Current view: top level - matcher-0.12.11/lib/src - description.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 21 0.0 %
Date: 2021-11-28 14:37:50 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
       2             : // for details. All rights reserved. Use of this source code is governed by a
       3             : // BSD-style license that can be found in the LICENSE file.
       4             : 
       5             : import 'interfaces.dart';
       6             : import 'pretty_print.dart';
       7             : 
       8             : /// The default implementation of [Description]. This should rarely need
       9             : /// substitution, although conceivably it is a place where other languages
      10             : /// could be supported.
      11             : class StringDescription implements Description {
      12             :   final StringBuffer _out = StringBuffer();
      13             : 
      14             :   /// Initialize the description with initial contents [init].
      15           0 :   StringDescription([String init = '']) {
      16           0 :     _out.write(init);
      17             :   }
      18             : 
      19           0 :   @override
      20           0 :   int get length => _out.length;
      21             : 
      22             :   /// Get the description as a string.
      23           0 :   @override
      24           0 :   String toString() => _out.toString();
      25             : 
      26             :   /// Append [text] to the description.
      27           0 :   @override
      28             :   Description add(String text) {
      29           0 :     _out.write(text);
      30             :     return this;
      31             :   }
      32             : 
      33             :   /// Change the value of the description.
      34           0 :   @override
      35             :   Description replace(String text) {
      36           0 :     _out.clear();
      37           0 :     return add(text);
      38             :   }
      39             : 
      40             :   /// Appends a description of [value]. If it is an IMatcher use its
      41             :   /// describe method; if it is a string use its literal value after
      42             :   /// escaping any embedded control characters; otherwise use its
      43             :   /// toString() value and wrap it in angular "quotes".
      44           0 :   @override
      45             :   Description addDescriptionOf(Object? value) {
      46           0 :     if (value is Matcher) {
      47           0 :       value.describe(this);
      48             :     } else {
      49           0 :       add(prettyPrint(value, maxLineLength: 80, maxItems: 25));
      50             :     }
      51             :     return this;
      52             :   }
      53             : 
      54             :   /// Append an [Iterable] [list] of objects to the description, using the
      55             :   /// specified [separator] and framing the list with [start]
      56             :   /// and [end].
      57           0 :   @override
      58             :   Description addAll(
      59             :       String start, String separator, String end, Iterable list) {
      60             :     var separate = false;
      61           0 :     add(start);
      62           0 :     for (var item in list) {
      63             :       if (separate) {
      64           0 :         add(separator);
      65             :       }
      66           0 :       addDescriptionOf(item);
      67             :       separate = true;
      68             :     }
      69           0 :     add(end);
      70             :     return this;
      71             :   }
      72             : }

Generated by: LCOV version 1.14