Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure assertEventsEqual() actually has events to test #316

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions source/dyaml/test/emitter.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module dyaml.test.emitter;

@safe unittest
{
import std.array : Appender;
import std.array : Appender, array;
import std.range : ElementType, isInputRange;

import dyaml : CollectionStyle, LineBreak, Loader, Mark, ScalarStyle;
Expand All @@ -17,11 +17,11 @@ module dyaml.test.emitter;
import dyaml.test.common : assertEventsEqual, run;

// Try to emit an event range.
static void emitTestCommon(T)(ref Appender!string emitStream, T events, bool canonical = false) @safe
static void emitTestCommon(T)(Appender!string* emitStream, T events, bool canonical = false) @safe
if (isInputRange!T && is(ElementType!T == Event))
{
auto emitter = Emitter!(typeof(emitStream), char)(emitStream, canonical, 2, 80, LineBreak.unix);
foreach (ref event; events)
foreach (event; events)
{
emitter.emit(event);
}
Expand All @@ -40,8 +40,8 @@ module dyaml.test.emitter;
{
//Must exist due to Anchor, Tags reference counts.
auto loader = Loader.fromFile(dataFilename);
auto events = loader.parse();
auto emitStream = Appender!string();
auto events = loader.parse().array;
auto emitStream = new Appender!string();
emitTestCommon(emitStream, events);

auto loader2 = Loader.fromString(emitStream.data);
Expand All @@ -60,10 +60,10 @@ module dyaml.test.emitter;
{
//Must exist due to Anchor, Tags reference counts.
auto loader = Loader.fromFile(canonicalFilename);
auto events = loader.parse();
auto events = loader.parse().array;
foreach (canonical; [false, true])
{
auto emitStream = Appender!string();
auto emitStream = new Appender!string();
emitTestCommon(emitStream, events, canonical);

auto loader2 = Loader.fromString(emitStream.data);
Expand All @@ -88,7 +88,7 @@ module dyaml.test.emitter;
{
//must exist due to Anchor, Tags reference counts
auto loader = Loader.fromFile(canonicalFilename);
auto events = loader.parse();
auto events = loader.parse().array;
foreach (flowStyle; [CollectionStyle.block, CollectionStyle.flow])
{
foreach (style; [ScalarStyle.literal, ScalarStyle.folded,
Expand Down Expand Up @@ -116,7 +116,7 @@ module dyaml.test.emitter;
}
styledEvents ~= event;
}
auto emitStream = Appender!string();
auto emitStream = new Appender!string();
emitTestCommon(emitStream, styledEvents);
auto loader2 = Loader.fromString(emitStream.data);
loader2.name = "TEST";
Expand Down