|
| 1 | +/* |
| 2 | + * The MIT License (MIT) |
| 3 | + * |
| 4 | + * Copyright (c) 2016-2025 Objectionary.com |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included |
| 14 | + * in all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + * SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +/* |
| 26 | + * @checkstyle PackageNameCheck (10 lines) |
| 27 | + * @checkstyle TrailingCommentCheck (3 lines) |
| 28 | + */ |
| 29 | +package EOorg.EOeolang; // NOPMD |
| 30 | + |
| 31 | +import org.eolang.Attr; |
| 32 | +import org.eolang.Data; |
| 33 | +import org.eolang.Dataized; |
| 34 | +import org.eolang.ExAbstract; |
| 35 | +import org.eolang.PhWith; |
| 36 | +import org.hamcrest.MatcherAssert; |
| 37 | +import org.hamcrest.Matchers; |
| 38 | +import org.junit.jupiter.api.Assertions; |
| 39 | +import org.junit.jupiter.api.Test; |
| 40 | + |
| 41 | +/** |
| 42 | + * Test case for {@link EOnumber$EOdiv}. |
| 43 | + * |
| 44 | + * @since 0.51 |
| 45 | + * @checkstyle TypeNameCheck (3 lines) |
| 46 | + */ |
| 47 | +@SuppressWarnings("PMD.AvoidDollarSigns") |
| 48 | +final class EOnumber$EOdivTest { |
| 49 | + |
| 50 | + @Test |
| 51 | + void throwsCorrectErrorForXAttr() { |
| 52 | + MatcherAssert.assertThat( |
| 53 | + "the message in the error is correct", |
| 54 | + Assertions.assertThrows( |
| 55 | + ExAbstract.class, |
| 56 | + () -> new Dataized( |
| 57 | + new PhWith( |
| 58 | + new PhWith( |
| 59 | + new EOnumber$EOdiv(), |
| 60 | + Attr.RHO, |
| 61 | + new Data.ToPhi(42) |
| 62 | + ), |
| 63 | + "x", |
| 64 | + new Data.ToPhi(true) |
| 65 | + ) |
| 66 | + ).take(), |
| 67 | + "addition with TRUE fails with a proper message that explains what happened" |
| 68 | + ).getMessage(), |
| 69 | + Matchers.equalTo("the 'x' attribute must be a number") |
| 70 | + ); |
| 71 | + } |
| 72 | + |
| 73 | + @Test |
| 74 | + void throwsCorrectErrorForRhoAttr() { |
| 75 | + MatcherAssert.assertThat( |
| 76 | + "the message in the error is correct", |
| 77 | + Assertions.assertThrows( |
| 78 | + ExAbstract.class, |
| 79 | + () -> new Dataized( |
| 80 | + new PhWith( |
| 81 | + new PhWith( |
| 82 | + new EOnumber$EOdiv(), |
| 83 | + Attr.RHO, |
| 84 | + new Data.ToPhi(true) |
| 85 | + ), |
| 86 | + "x", |
| 87 | + new Data.ToPhi(42) |
| 88 | + ) |
| 89 | + ).take(), |
| 90 | + "EOnumber must be a number" |
| 91 | + ).getMessage(), |
| 92 | + Matchers.equalTo("the 'ρ' attribute must be a number") |
| 93 | + ); |
| 94 | + } |
| 95 | + |
| 96 | +} |
0 commit comments