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

No tests for insertAt for lists #62

Open
kjbrown-sandbox opened this issue Aug 20, 2023 · 1 comment
Open

No tests for insertAt for lists #62

kjbrown-sandbox opened this issue Aug 20, 2023 · 1 comment

Comments

@kjbrown-sandbox
Copy link

DoublyLinkedList (as well as all the other list types) don't have any testing for the function insertAt. Also, a few of the other functions could be tested more thoroughly. I added some tests to the file on a branch and could make a PR if I were given permission; otherwise, here's the updated file:

export function test_list(list: List<number>): void {
    list.append(5);
    list.append(7);
    list.append(9);

    expect(list.get(2)).toEqual(9);
    expect(list.removeAt(1)).toEqual(7);
    expect(list.length).toEqual(2);
    expect(list.get(1)).toEqual(9);

    list.append(11);
    list.append(15);
    expect(list.removeAt(1)).toEqual(9);
    expect(list.remove(9)).toEqual(undefined);
    expect(list.removeAt(0)).toEqual(5);
    expect(list.removeAt(1)).toEqual(15);
    expect(list.removeAt(0)).toEqual(11);
    expect(list.length).toEqual(0);

    list.prepend(5);
    list.prepend(7);
    list.prepend(9);

    expect(list.get(2)).toEqual(5);
    expect(list.get(0)).toEqual(9);
    expect(list.remove(9)).toEqual(9);
    expect(list.length).toEqual(2);
    expect(list.get(0)).toEqual(7);

    list.insertAt(10, 0);
    list.insertAt(13, 2);
    list.insertAt(1, 4);

    expect(list.get(0)).toEqual(10);
    expect(list.get(1)).toEqual(7);
    expect(list.get(2)).toEqual(13);
    expect(list.get(3)).toEqual(5);
    expect(list.get(4)).toEqual(1);
    expect(list.insertAt(6, 6)).toEqual(undefined);
    expect(list.length).toEqual(5);
}
@FX-Wood
Copy link

FX-Wood commented Sep 11, 2023

I also had this problem. You should fork the repo and make a pull request that way. That's the normal way to open PRs to repositories you don't own. The rough steps are:

  1. make a fork of the repo ( https://docs.github.com/en/get-started/quickstart/fork-a-repo )
  2. either clone that and remake your branch (bonus if you want to try pushing the existing branch to the fork)
  3. open a PR from your fork to this repo ( https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants