mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 05:32:26 +08:00
Update RandomStringGenerator
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
import 'dart:math';
|
||||
|
||||
class RandomStringGenerator {
|
||||
static const _chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890';
|
||||
static Random _rnd = Random();
|
||||
static const _chars =
|
||||
'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890';
|
||||
static Random rnd = Random();
|
||||
|
||||
static String getRandomString(int length) => String.fromCharCodes(Iterable.generate(
|
||||
length, (_) => _chars.codeUnitAt(_rnd.nextInt(_chars.length))));
|
||||
static String getRandomString(int length) =>
|
||||
String.fromCharCodes(Iterable.generate(
|
||||
length, (_) => _chars.codeUnitAt(rnd.nextInt(_chars.length))));
|
||||
|
||||
static String getRandomStringLines(int lines, int length) {
|
||||
List<String> result = [];
|
||||
|
@ -368,13 +368,15 @@ void main() {
|
||||
});
|
||||
|
||||
test('Testing formatBody for html subtype values with random values', () {
|
||||
String body5 = '''<html>${getRandomStringLines(100, 10000)}</html>''';
|
||||
String body5 =
|
||||
'''<html>${RandomStringGenerator.getRandomStringLines(100, 10000)}</html>''';
|
||||
expect(formatBody(body5, mediaTypeHtml), null);
|
||||
});
|
||||
test(
|
||||
'Testing formatBody for html subtype values with random values within limit',
|
||||
() {
|
||||
String body6 = '''<html>${getRandomStringLines(100, 190)}</html>''';
|
||||
String body6 =
|
||||
'''<html>${RandomStringGenerator.getRandomStringLines(100, 190)}</html>''';
|
||||
expect(formatBody(body6, mediaTypeHtml), body6);
|
||||
});
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ void main() async {
|
||||
});
|
||||
testWidgets('Testing for code previewer when code is of 1000 lines',
|
||||
(tester) async {
|
||||
String codeLines = getRandomStringLines(1000, 20);
|
||||
String codeLines = RandomStringGenerator.getRandomStringLines(1000, 20);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
title: 'Code Previewer',
|
||||
|
Reference in New Issue
Block a user