-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Janik-Haag/develop
intialize tests
- Loading branch information
Showing
4 changed files
with
27 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
{ lib, ... }: { | ||
networking = { | ||
/* | ||
/* | ||
Generates inclusive portrange given a lower and a higher number | ||
Type: | ||
utils.networking.portrange:: Int -> Int -> [ Int ] | ||
*/ | ||
portrange = | ||
from: | ||
to: | ||
let | ||
helper = input: | ||
if input.counter >= 0 then | ||
helper | ||
{ | ||
list = [ (from + input.counter) ] ++ input.list; | ||
counter = input.counter - 1; | ||
} else input.list; | ||
in | ||
lib.throwIf (from > to) "the second input has to be larger then the first one, otherwise you have a negative range which is impossible or not a range." | ||
helper | ||
{ list = [ ]; counter = to - from; } | ||
; | ||
}; | ||
portrange = | ||
from: | ||
to: | ||
let | ||
helper = input: | ||
if input.counter >= 0 then | ||
helper | ||
{ | ||
list = [ (from + input.counter) ] ++ input.list; | ||
counter = input.counter - 1; | ||
} else input.list; | ||
in | ||
lib.throwIf (from > to) "the second input has to be larger then the first one, otherwise you have a negative range which is impossible or not a range." | ||
helper | ||
{ list = [ ]; counter = to - from; } | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ self, lib, utils }: | ||
{ | ||
testPortrange = { | ||
expr = utils.networking.portrange 8000 8100; | ||
expected = [ 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 ]; | ||
}; | ||
} |