Compare commits
4 commits
686fd07e08
...
8abebb692a
Author | SHA1 | Date | |
---|---|---|---|
|
8abebb692a | ||
|
4bb3629a76 | ||
|
cc34c03648 | ||
|
c5e034c3ac |
4 changed files with 58 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@ words.txt
|
|||
compile_commands.json
|
||||
lab2/edit
|
||||
lab2/spell
|
||||
lab3/tabletest
|
||||
|
|
33
lab3/Makefile
Normal file
33
lab3/Makefile
Normal file
|
@ -0,0 +1,33 @@
|
|||
CXX = g++
|
||||
CXXFLAGS = -Wall -Wextra -Wpedantic -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -std=c++17
|
||||
#CXXFLAGS += -Werror
|
||||
|
||||
SRC = $(wildcard *.cc)
|
||||
HDR = $(wildcard *.h)
|
||||
OBJ = $(SRC:.cc=.o)
|
||||
|
||||
all: tabletest $(OBJ)
|
||||
|
||||
tabletest: $(OBJ)
|
||||
@echo "Building & linking $@"
|
||||
@$(CXX) $(CXXFLAGS) $^ -o $@
|
||||
|
||||
%.o:%.cc
|
||||
@echo "Building $@"
|
||||
@$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
lint: clang-tidy cppcheck clang-format
|
||||
|
||||
clang-tidy:
|
||||
clang-tidy $(SRC) -- $(CXXFLAGS)
|
||||
|
||||
cppcheck:
|
||||
cppcheck --enable=all --language=c++ --std=c++17 --suppress=missingIncludeSystem -I/usr/include $(SRC) $(HDR)
|
||||
|
||||
clang-format:
|
||||
clang-format -i $(SRC) $(HDR)
|
||||
|
||||
clean:
|
||||
rm -f *.o spell edit
|
||||
|
||||
.PHONY: clean all lint clang-tidy cppcheck clang-format
|
|
@ -56,8 +56,8 @@ User UserTable::find(int c) const
|
|||
while (low < high && ! found) {
|
||||
mid = (low + high) / 2;
|
||||
//
|
||||
int midnbr = users[mid].getCardNbr();
|
||||
if (midnbr = c) {
|
||||
const int midnbr = users[mid].getCardNbr();
|
||||
if (c == midnbr) {
|
||||
found = true;
|
||||
} else if (users[mid].getCardNbr() < c) {
|
||||
low = mid + 1;
|
||||
|
|
22
lab3/UserTableTest.cc
Normal file
22
lab3/UserTableTest.cc
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "UserTable.h"
|
||||
#include "User.h"
|
||||
#include <cassert>
|
||||
|
||||
int main() {
|
||||
// Two identical users
|
||||
User u1 = User(1234, "Name Nameson");
|
||||
User u2 = User(1234, "Name Nameson");
|
||||
|
||||
assert(u1.getName() == u2.getName());
|
||||
assert(u1.getCardNbr() == u2.getCardNbr());
|
||||
|
||||
// Two different users
|
||||
User u3 = User(1200, "Name Surname");
|
||||
User u4 = User(1201, "Name Nameson");
|
||||
|
||||
assert(u3.getName() != u4.getName());
|
||||
assert(u3.getCardNbr() != u4.getCardNbr());
|
||||
|
||||
UserTable ut1 = UserTable("users.txt");
|
||||
}
|
||||
|
Loading…
Reference in a new issue