• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Glusk / srp6-variables / 171

pending completion
171

push

travis-ci-com

web-flow
Merge pull request #83 from Glusk/issue-77

#77 Added. Missing tests.

15 of 15 new or added lines in 2 files covered. (100.0%)

230 of 245 relevant lines covered (93.88%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com.github.glusk.srp6_variables/com/github/glusk/srp6_variables/ZeroPadded.java
1
package com.github.glusk.srp6_variables;
2

3
import java.nio.ByteOrder;
4

5
import com.github.glusk.caesar.AbstractBytes;
6

7
/** A zero-padded SRP-6 Integer Variable Bytes view. */
8
public final class ZeroPadded extends AbstractBytes {
9
    /** An SRP-6 Integer Variable to zero-pad. */
10
    private final SRP6IntegerVariable variableToZeroPad;
11
    /**
12
     * The byte order to use when converting {@code variableToZeroPad}
13
     * to Bytes.
14
     */
15
    private final ByteOrder order;
16
    /**
17
     * {@code variableToZeroPad} will be zero-padded to
18
     * {@code variableToPadTo.bytes(order).asArray().length}.
19
     */
20
    private final SRP6IntegerVariable variableToPadTo;
21

22
    /**
23
     * Creates a new ZeroPadded Bytes object by wrapping
24
     * {@code variableToZeroPad}, {@code order}, and {@code} variableToPadTo}.
25
     *
26
     * @param variableToZeroPad an SRP-6 Integer Variable to zero-pad
27
     * @param order the byte order to use when converting
28
     *              {@code variableToZeroPad} to Bytes
29
     * @param variableToPadTo {@code variableToZeroPad} will be zero-padded to
30
     *                    {@code variableToPadTo.bytes(order).asArray().length}
31
     */
32
    @SuppressWarnings("checkstyle:hiddenfield")
33
    public ZeroPadded(
34
        final SRP6IntegerVariable variableToZeroPad,
35
        final ByteOrder order,
36
        final SRP6IntegerVariable variableToPadTo
37
    ) {
×
38
        this.variableToZeroPad = variableToZeroPad;
×
39
        this.order = order;
×
40
        this.variableToPadTo = variableToPadTo;
×
41
    }
×
42
    /**
43
     * {@inheritDoc}
44
     *
45
     * @throws IllegalArgumentException If {@code variableToZeroPad} has a
46
     * greater byte length than {@code variableToPadTo}, an
47
     * {@code SRP6PaddingException} gets thrown. This method catches it and
48
     * re-throws it as and {@code IllegalArgumentException}. More info:
49
     * {@linkplain SRP6IntegerVariable#bytes(ByteOrder,int)}
50
     */
51
    @Override
52
    public byte[] asArray() {
53
        try {
54
            return this.variableToZeroPad.bytes(
×
55
                this.order,
56
                this.variableToPadTo.bytes(this.order).asArray().length
×
57
            ).asArray();
×
58
        } catch (SRP6PaddingException e) {
×
59
            throw new IllegalArgumentException(e);
×
60
        }
61
    }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc