Skip to content

GitLab

  • Menu
    • Projects Groups Snippets
      Help
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • P project01
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cs2-22wi
  • project01
  • Issues
  • #1

Closed
Open
Created 3 years ago by James C Bowden@jbowdenOwner
  • New issue

  • Report abuse

  • New issue

  • Report abuse

random constructor not thoroughly tested

Closed

random constructor not thoroughly tested

This is inspired by this chunk of code, which works until the last tests for student. Barron reported.

public SubstitutionCipher(String ciphertext) {
        this.ciphertext = ciphertext;
        HashMap<Character, Character> key = new HashMap<Character, Character>();

        for (char c : ciphertext.toCharArray()) {
            key.putIfAbsent(c, c);
        }
        this.key = key;

        for (int i = 0; i < 10000; i++) {
            this.key = randomSwap().key;
        }
    }

I think they can get away with this because the test case for randomswap has long ciphertext and thus most letters actually get added in. Could fix by making an explicit case with a smaller ciphertext such that randomswap should hit an NPE or something of the sort relatively quickly from trying to get a letter that never actually got added to the key.

Edited 3 years ago by James C Bowden
  1. Oh no!

    You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico.

    Incoming!

    Drop your designs to start your upload.

Linked issues
0


  • James C Bowden @jbowden changed the description 3 years ago

    changed the description

  • Snigdha Saha
    Snigdha Saha @snigdha · 2 years ago
    Developer

    fixed - added a new test that tests the SubstitutionCipher constructor with only a ciphertext as input, with a smaller text.

  • Snigdha Saha @snigdha closed 2 years ago

    closed

  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
0 Assignees
None
Assign to
Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Due date
None
None
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only team members with at least Reporter access will be able to see and leave comments on the issue.

Lock issue
Unlocked
2
2 participants
Snigdha Saha
James C Bowden
Reference: cs2-22wi/project01#1

Menu

Projects Groups Snippets
Help