Skip to content

Commit 74f7cf5

Browse files
committed
feat: Enhance message handling with HeapString for improved memory management
1 parent 6308590 commit 74f7cf5

File tree

6 files changed

+43
-17
lines changed

6 files changed

+43
-17
lines changed

operation-snapshots.md

0 Bytes

# Operation Snapshots This file contains snapshots of all assertion operations with both positive and negated failure variants. ## equal (scalar) ### Positive fail ```d expect(5).to.equal(3); ``` ``` ASSERTION FAILED: 5 should equal 3. OPERATION: equal ACTUAL: 5 EXPECTED: 3 source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect(5).to.not.equal(5); ``` ``` ASSERTION FAILED: 5 should not equal 5. OPERATION: not equal ACTUAL: 5 EXPECTED: not 5 source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## equal (string) ### Positive fail ```d expect("hello").to.equal("world"); ``` ``` ASSERTION FAILED: hello should equal world. OPERATION: equal ACTUAL: hello EXPECTED: world source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect("hello").to.not.equal("hello"); ``` ``` ASSERTION FAILED: hello should not equal hello. OPERATION: not equal ACTUAL: hello EXPECTED: not hello source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## equal (array) ### Positive fail ```d expect([1,2,3]).to.equal([1,2,4]); ``` ``` ASSERTION FAILED: [1, 2, 3] should equal [1, 2, 4]. OPERATION: equal ACTUAL: [1, 2, 3] EXPECTED: [1, 2, 4] source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect([1,2,3]).to.not.equal([1,2,3]); ``` ``` ASSERTION FAILED: [1, 2, 3] should not equal [1, 2, 3]. OPERATION: not equal ACTUAL: [1, 2, 3] EXPECTED: not [1, 2, 3] source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## contain (string) ### Positive fail ```d expect("hello").to.contain("xyz"); ``` ``` ASSERTION FAILED: hello should contain xyz. is missing from hello. OPERATION: contain ACTUAL: hello EXPECTED: to contain xyz source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect("hello").to.not.contain("ell"); ``` ``` ASSERTION FAILED: hello should not contain ell. is present in hello. OPERATION: not contain ACTUAL: hello EXPECTED: not to contain ell source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## contain (array) ### Positive fail ```d expect([1,2,3]).to.contain(5); ``` ``` ASSERTION FAILED: [1, 2, 3] should contain 5. 5 is missing from [1, 2, 3]. OPERATION: contain ACTUAL: [1, 2, 3] EXPECTED: to contain 5 source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect([1,2,3]).to.not.contain(2); ``` ``` ASSERTION FAILED: [1, 2, 3] should not contain 2. 2 is present in [1, 2, 3]. OPERATION: not contain ACTUAL: [1, 2, 3] EXPECTED: not to contain 2 source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## containOnly ### Positive fail ```d expect([1,2,3]).to.containOnly([1,2]); ``` ``` ASSERTION FAILED: [1, 2, 3] should contain only [1, 2]. OPERATION: containOnly ACTUAL: [1, 2, 3] EXPECTED: to contain only [1, 2] source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect([1,2,3]).to.not.containOnly([1,2,3]); ``` ``` ASSERTION FAILED: [1, 2, 3] should not contain only [1, 2, 3]. OPERATION: not containOnly ACTUAL: [1, 2, 3] EXPECTED: not to contain only [1, 2, 3] source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## startWith ### Positive fail ```d expect("hello").to.startWith("xyz"); ``` ``` ASSERTION FAILED: hello should start with xyz. hello does not start with xyz. OPERATION: startWith ACTUAL: hello EXPECTED: to start with xyz source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect("hello").to.not.startWith("hel"); ``` ``` ASSERTION FAILED: hello should not start with hel. hello starts with hel. OPERATION: not startWith ACTUAL: hello EXPECTED: not to start with hel source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## endWith ### Positive fail ```d expect("hello").to.endWith("xyz"); ``` ``` ASSERTION FAILED: hello should end with xyz. hello does not end with xyz. OPERATION: endWith ACTUAL: hello EXPECTED: to end with xyz source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect("hello").to.not.endWith("llo"); ``` ``` ASSERTION FAILED: hello should not end with llo. hello ends with llo. OPERATION: not endWith ACTUAL: hello EXPECTED: not to end with llo source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## beNull ### Positive fail ```d Object obj = new Object(); expect(obj).to.beNull; ``` ``` ASSERTION FAILED: Object(4739032064) should be null. OPERATION: beNull ACTUAL: object.Object EXPECTED: null source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d Object obj = null; expect(obj).to.not.beNull; ``` ``` ASSERTION FAILED: null should not be null. OPERATION: not beNull ACTUAL: object.Object EXPECTED: not null source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## approximately (scalar) ### Positive fail ```d expect(0.5).to.be.approximately(0.3, 0.1); ``` ``` ASSERTION FAILED: 0.5 should be approximately 0.3±0.1. 0.5 is not approximately 0.3±0.1. OPERATION: approximately ACTUAL: 0.5 EXPECTED: 0.3±0.1 source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect(0.351).to.not.be.approximately(0.35, 0.01); ``` ``` ASSERTION FAILED: 0.351 should not be approximately 0.35±0.01. 0.351 is approximately 0.35±0.01. OPERATION: not approximately ACTUAL: 0.351 EXPECTED: 0.35±0.01 source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## approximately (array) ### Positive fail ```d expect([0.5]).to.be.approximately([0.3], 0.1); ``` ``` ASSERTION FAILED: [0.5] should be approximately [0.3]±0.1. OPERATION: approximately ACTUAL: [0.5] EXPECTED: [0.3±0.1] source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect([0.35]).to.not.be.approximately([0.35], 0.01); ``` ``` ASSERTION FAILED: [0.35] should not be approximately [0.35]±0.01. OPERATION: not approximately ACTUAL: [0.35] EXPECTED: [0.35±0.01] source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## greaterThan ### Positive fail ```d expect(3).to.be.greaterThan(5); ``` ``` ASSERTION FAILED: 3 should be greater than 5. 3 is less than or equal to 5. OPERATION: greaterThan ACTUAL: 3 EXPECTED: greater than 5 source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect(5).to.not.be.greaterThan(3); ``` ``` ASSERTION FAILED: 5 should not be greater than 3. 5 is greater than 3. OPERATION: not greaterThan ACTUAL: 5 EXPECTED: less than or equal to 3 source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## lessThan ### Positive fail ```d expect(5).to.be.lessThan(3); ``` ``` ASSERTION FAILED: 5 should be less than 3. 5 is greater than or equal to 3. OPERATION: lessThan ACTUAL: 5 EXPECTED: less than 3 source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect(3).to.not.be.lessThan(5); ``` ``` ASSERTION FAILED: 3 should not be less than 5. 3 is less than 5. OPERATION: not lessThan ACTUAL: 3 EXPECTED: greater than or equal to 5 source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## between ### Positive fail ```d expect(10).to.be.between(1, 5); ``` ``` ASSERTION FAILED: 10 should be between 1 and 5. 10 is greater than or equal to 5. OPERATION: between ACTUAL: 10 EXPECTED: a value inside (1, 5) interval source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect(3).to.not.be.between(1, 5); ``` ``` ASSERTION FAILED: 3 should not be between 1 and 5. OPERATION: not between ACTUAL: 3 EXPECTED: a value outside (1, 5) interval source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## greaterOrEqualTo ### Positive fail ```d expect(3).to.be.greaterOrEqualTo(5); ``` ``` ASSERTION FAILED: 3 should be greater or equal to 5. 3 is less than 5. OPERATION: greaterOrEqualTo ACTUAL: 3 EXPECTED: greater or equal than 5 source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect(5).to.not.be.greaterOrEqualTo(3); ``` ``` ASSERTION FAILED: 5 should not be greater or equal to 3. 5 is greater or equal than 3. OPERATION: not greaterOrEqualTo ACTUAL: 5 EXPECTED: less than 3 source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## lessOrEqualTo ### Positive fail ```d expect(5).to.be.lessOrEqualTo(3); ``` ``` ASSERTION FAILED: 5 should be less or equal to 3. 5 is greater than 3. OPERATION: lessOrEqualTo ACTUAL: 5 EXPECTED: less or equal to 3 source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect(3).to.not.be.lessOrEqualTo(5); ``` ``` ASSERTION FAILED: 3 should not be less or equal to 5. 3 is less or equal to 5. OPERATION: not lessOrEqualTo ACTUAL: 3 EXPECTED: greater than 5 source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ``` ## instanceOf ### Positive fail ```d expect(new Object()).to.be.instanceOf!Exception; ``` ``` ASSERTION FAILED: Object(4738967413) should be instance of "object.Exception". Object(4738967413) is instance of object.Object. OPERATION: instanceOf ACTUAL: typeof object.Object EXPECTED: typeof object.Exception source/fluentasserts/operations/snapshot.d:107 > 107: auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation; ``` ### Negated fail ```d expect(new Exception("test")).to.not.be.instanceOf!Object; ``` ``` ASSERTION FAILED: Exception(4738996486) should not be instance of "object.Object". Exception(4738996486) is instance of object.Exception. OPERATION: not instanceOf ACTUAL: typeof object.Exception EXPECTED: not typeof object.Object source/fluentasserts/operations/snapshot.d:122 > 122: auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation; ```

Operation Snapshots

This file contains snapshots of all assertion operations with both positive and negated failure variants.

equal (scalar)

Positive fail

expect(5).to.equal(3);
ASSERTION FAILED: 5 should equal 3.
OPERATION: equal

  ACTUAL: <int> 5
EXPECTED: <int> 3

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect(5).to.not.equal(5);
ASSERTION FAILED: 5 should not equal 5.
OPERATION: not equal

  ACTUAL: <int> 5
EXPECTED: <int> not 5

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

equal (string)

Positive fail

expect("hello").to.equal("world");
ASSERTION FAILED: hello should equal world.
OPERATION: equal

  ACTUAL: <string> hello
EXPECTED: <string> world

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect("hello").to.not.equal("hello");
ASSERTION FAILED: hello should not equal hello.
OPERATION: not equal

  ACTUAL: <string> hello
EXPECTED: <string> not hello

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

equal (array)

Positive fail

expect([1,2,3]).to.equal([1,2,4]);
ASSERTION FAILED: [1, 2, 3] should equal [1, 2, 4].
OPERATION: equal

  ACTUAL: <int[]> [1, 2, 3]
EXPECTED: <int[]> [1, 2, 4]

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect([1,2,3]).to.not.equal([1,2,3]);
ASSERTION FAILED: [1, 2, 3] should not equal [1, 2, 3].
OPERATION: not equal

  ACTUAL: <int[]> [1, 2, 3]
EXPECTED: <int[]> not [1, 2, 3]

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

contain (string)

Positive fail

expect("hello").to.contain("xyz");
ASSERTION FAILED: hello should contain xyz. xyz is missing from hello.
OPERATION: contain

  ACTUAL: <string> hello
EXPECTED: <string> to contain xyz

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect("hello").to.not.contain("ell");
ASSERTION FAILED: hello should not contain ell. ell is present in hello.
OPERATION: not contain

  ACTUAL: <string> hello
EXPECTED: <string> not to contain ell

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

contain (array)

Positive fail

expect([1,2,3]).to.contain(5);
ASSERTION FAILED: [1, 2, 3] should contain 5. 5 is missing from [1, 2, 3].
OPERATION: contain

  ACTUAL: <int[]> [1, 2, 3]
EXPECTED: <int> to contain 5

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect([1,2,3]).to.not.contain(2);
ASSERTION FAILED: [1, 2, 3] should not contain 2. 2 is present in [1, 2, 3].
OPERATION: not contain

  ACTUAL: <int[]> [1, 2, 3]
EXPECTED: <int> not to contain 2

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

containOnly

Positive fail

expect([1,2,3]).to.containOnly([1,2]);
ASSERTION FAILED: [1, 2, 3] should contain only [1, 2].
OPERATION: containOnly

  ACTUAL: <int[]> [1, 2, 3]
EXPECTED: <int[]> to contain only [1, 2]

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect([1,2,3]).to.not.containOnly([1,2,3]);
ASSERTION FAILED: [1, 2, 3] should not contain only [1, 2, 3].
OPERATION: not containOnly

  ACTUAL: <int[]> [1, 2, 3]
EXPECTED: <int[]> not to contain only [1, 2, 3]

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

startWith

Positive fail

expect("hello").to.startWith("xyz");
ASSERTION FAILED: hello should start with xyz. hello does not start with xyz.
OPERATION: startWith

  ACTUAL: <string> hello
EXPECTED: <string> to start with xyz

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect("hello").to.not.startWith("hel");
ASSERTION FAILED: hello should not start with hel. hello starts with hel.
OPERATION: not startWith

  ACTUAL: <string> hello
EXPECTED: <string> not to start with hel

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

endWith

Positive fail

expect("hello").to.endWith("xyz");
ASSERTION FAILED: hello should end with xyz. hello does not end with xyz.
OPERATION: endWith

  ACTUAL: <string> hello
EXPECTED: <string> to end with xyz

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect("hello").to.not.endWith("llo");
ASSERTION FAILED: hello should not end with llo. hello ends with llo.
OPERATION: not endWith

  ACTUAL: <string> hello
EXPECTED: <string> not to end with llo

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

beNull

Positive fail

Object obj = new Object(); expect(obj).to.beNull;
ASSERTION FAILED: Object(4696048229) should be null.
OPERATION: beNull

  ACTUAL: <object.Object> object.Object
EXPECTED: <unknown> null

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

Object obj = null; expect(obj).to.not.beNull;
ASSERTION FAILED: null should not be null.
OPERATION: not beNull

  ACTUAL: <object.Object> object.Object
EXPECTED: <unknown> not null

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

approximately (scalar)

Positive fail

expect(0.5).to.be.approximately(0.3, 0.1);
ASSERTION FAILED: 0.5 should be approximately 0.3±0.1. 0.5 is not approximately 0.3±0.1.
OPERATION: approximately

  ACTUAL: <double> 0.5
EXPECTED: <double> 0.3±0.1

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect(0.351).to.not.be.approximately(0.35, 0.01);
ASSERTION FAILED: 0.351 should not be approximately 0.35±0.01. 0.351 is approximately 0.35±0.01.
OPERATION: not approximately

  ACTUAL: <double> 0.351
EXPECTED: <double> 0.35±0.01

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

approximately (array)

Positive fail

expect([0.5]).to.be.approximately([0.3], 0.1);
ASSERTION FAILED: [0.5] should be approximately [0.3]±0.1.
OPERATION: approximately

  ACTUAL: <double[]> [0.5]
EXPECTED: <double[]> [0.3±0.1]

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect([0.35]).to.not.be.approximately([0.35], 0.01);
ASSERTION FAILED: [0.35] should not be approximately [0.35]±0.01.
OPERATION: not approximately

  ACTUAL: <double[]> [0.35]
EXPECTED: <double[]> [0.35±0.01]

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

greaterThan

Positive fail

expect(3).to.be.greaterThan(5);
ASSERTION FAILED: 3 should be greater than 5. 3 is less than or equal to 5.
OPERATION: greaterThan

  ACTUAL: <int> 3
EXPECTED: <int> greater than 5

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect(5).to.not.be.greaterThan(3);
ASSERTION FAILED: 5 should not be greater than 3. 5 is greater than 3.
OPERATION: not greaterThan

  ACTUAL: <int> 5
EXPECTED: <int> less than or equal to 3

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

lessThan

Positive fail

expect(5).to.be.lessThan(3);
ASSERTION FAILED: 5 should be less than 3. 5 is greater than or equal to 3.
OPERATION: lessThan

  ACTUAL: <int> 5
EXPECTED: <int> less than 3

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect(3).to.not.be.lessThan(5);
ASSERTION FAILED: 3 should not be less than 5. 3 is less than 5.
OPERATION: not lessThan

  ACTUAL: <int> 3
EXPECTED: <int> greater than or equal to 5

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

between

Positive fail

expect(10).to.be.between(1, 5);
ASSERTION FAILED: 10 should be between 1 and 5. 10 is greater than or equal to 5.
OPERATION: between

  ACTUAL: <int> 10
EXPECTED: <int> a value inside (1, 5) interval

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect(3).to.not.be.between(1, 5);
ASSERTION FAILED: 3 should not be between 1 and 5. 
OPERATION: not between

  ACTUAL: <int> 3
EXPECTED: <int> a value outside (1, 5) interval

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

greaterOrEqualTo

Positive fail

expect(3).to.be.greaterOrEqualTo(5);
ASSERTION FAILED: 3 should be greater or equal to 5. 3 is less than 5.
OPERATION: greaterOrEqualTo

  ACTUAL: <int> 3
EXPECTED: <int> greater or equal than 5

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect(5).to.not.be.greaterOrEqualTo(3);
ASSERTION FAILED: 5 should not be greater or equal to 3. 5 is greater or equal than 3.
OPERATION: not greaterOrEqualTo

  ACTUAL: <int> 5
EXPECTED: <int> less than 3

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

lessOrEqualTo

Positive fail

expect(5).to.be.lessOrEqualTo(3);
ASSERTION FAILED: 5 should be less or equal to 3. 5 is greater than 3.
OPERATION: lessOrEqualTo

  ACTUAL: <int> 5
EXPECTED: <int> less or equal to 3

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect(3).to.not.be.lessOrEqualTo(5);
ASSERTION FAILED: 3 should not be less or equal to 5. 3 is less or equal to 5.
OPERATION: not lessOrEqualTo

  ACTUAL: <int> 3
EXPECTED: <int> greater than 5

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

instanceOf

Positive fail

expect(new Object()).to.be.instanceOf!Exception;
ASSERTION FAILED: Object(4697060295) should be instance of "object.Exception". Object(4697060295) is instance of object.Object.
OPERATION: instanceOf

  ACTUAL: <object.Object> typeof object.Object
EXPECTED: <object.Exception> typeof object.Exception

source/fluentasserts/operations/snapshot.d:107
>  107:        auto posEval = ({ mixin(c.code ~ ";"); }).recordEvaluation;

Negated fail

expect(new Exception("test")).to.not.be.instanceOf!Object;
ASSERTION FAILED: Exception(4696968534) should not be instance of "object.Object". Exception(4696968534) is instance of object.Exception.
OPERATION: not instanceOf

  ACTUAL: <object.Exception> typeof object.Exception
EXPECTED: <object.Object> not typeof object.Object

source/fluentasserts/operations/snapshot.d:122
>  122:        auto negEval = ({ mixin(c.negCode ~ ";"); }).recordEvaluation;

source/fluentasserts/core/evaluation.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ struct Evaluation {
168168

169169
printer.info("ASSERTION FAILED: ");
170170

171-
foreach(message; result.messages) {
171+
foreach(ref message; result.messages) {
172172
printer.print(message);
173173
}
174174

source/fluentasserts/core/heapdata.d

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ struct HeapData(T) {
190190
ptr[_length++] = item;
191191
}
192192
}
193+
194+
/// Appends contents from another HeapData.
195+
void put(ref const HeapData other) @trusted @nogc nothrow {
196+
if (other._length == 0) {
197+
return;
198+
}
199+
put(other[]);
200+
}
201+
202+
/// Appends contents from another HeapData (rvalue).
203+
void put(const HeapData other) @trusted @nogc nothrow {
204+
if (other._length == 0) {
205+
return;
206+
}
207+
put(other[]);
208+
}
193209
}
194210

195211
/// Returns the contents as a slice.

source/fluentasserts/results/asserts.d

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import std.conv;
77
import ddmp.diff;
88

99
import fluentasserts.results.message : Message, ResultGlyphs;
10+
import fluentasserts.core.heapdata : HeapString;
1011
public import fluentasserts.core.array : FixedArray, FixedAppender, FixedStringArray;
1112

1213
@safe:
@@ -94,18 +95,25 @@ struct AssertResult {
9495
.replace("\t", ResultGlyphs.tab);
9596
}
9697

97-
/// Returns the message as a plain string.
98-
string messageString() nothrow @trusted inout {
99-
string result;
100-
foreach (m; messages) {
101-
result ~= m.text;
98+
/// Returns the message as a HeapString.
99+
HeapString messageString() nothrow @trusted @nogc inout {
100+
// Calculate total size needed
101+
size_t totalSize = 0;
102+
foreach (ref m; messages) {
103+
totalSize += m.text.length;
104+
}
105+
106+
// Preallocate and copy
107+
HeapString result = HeapString.create(totalSize);
108+
foreach (ref m; messages) {
109+
result.put(m.text[]);
102110
}
103111
return result;
104112
}
105113

106114
/// Converts the entire result to a displayable string.
107115
string toString() nothrow @trusted inout {
108-
return messageString();
116+
return messageString()[].idup;
109117
}
110118

111119
/// Adds a message to the result.

source/fluentasserts/results/message.d

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module fluentasserts.results.message;
44

55
import std.string;
66

7+
import fluentasserts.core.heapdata : HeapString, toHeapString;
8+
79
@safe:
810

911
/// Glyphs used to display special characters in the results.
@@ -119,23 +121,23 @@ struct Message {
119121
Type type;
120122

121123
/// The text content of this message
122-
string text;
124+
HeapString text;
123125

124126
/// Constructs a message with the given type and text.
125-
this(Type type, string text) nothrow @nogc {
127+
this(Type type, string text) nothrow @trusted @nogc {
126128
this.type = type;
127-
this.text = text;
129+
this.text = toHeapString(text);
128130
}
129131

130132
/// Returns the raw text content. Use formattedText() for display with special formatting.
131-
string toString() nothrow @nogc inout {
132-
return text;
133+
const(char)[] toString() nothrow @nogc inout {
134+
return text[];
133135
}
134136

135137
/// Returns the text with special character replacements and type-specific formatting.
136138
/// This allocates memory and should be used only for display purposes.
137139
string formattedText() nothrow inout {
138-
string content = text;
140+
string content = text[].idup;
139141

140142
if (type == Type.value || type == Type.insert || type == Type.delete_) {
141143
content = content
@@ -147,13 +149,13 @@ struct Message {
147149

148150
switch (type) {
149151
case Type.title:
150-
return "\n\n" ~ text ~ "\n";
152+
return "\n\n" ~ text[].idup ~ "\n";
151153
case Type.insert:
152154
return "[-" ~ content ~ "]";
153155
case Type.delete_:
154156
return "[+" ~ content ~ "]";
155157
case Type.category:
156-
return "\n" ~ text ~ "";
158+
return "\n" ~ text[].idup ~ "";
157159
default:
158160
return content;
159161
}

source/fluentasserts/results/printer.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ version (unittest) {
5050
import std.conv : to;
5151

5252
try {
53-
buffer ~= "[" ~ message.type.to!string ~ ":" ~ message.text ~ "]";
53+
buffer ~= "[" ~ message.type.to!string ~ ":" ~ message.text[].idup ~ "]";
5454
} catch (Exception) {
5555
buffer ~= "ERROR";
5656
}
@@ -164,7 +164,7 @@ class StringResultPrinter : ResultPrinter {
164164
nothrow:
165165

166166
void print(Message message) {
167-
buffer.put(message.text);
167+
buffer.put(message.text[]);
168168
}
169169

170170
void primary(string text) {

0 commit comments

Comments
 (0)